Commit Graph

26 Commits

Author SHA1 Message Date
Steve Klabnik 426ba307ab fail -> panic 2014-10-30 00:25:47 -04:00
Sébastien Crozet 5ba9f27530 Add quaternions.
Fix #24.
2014-10-14 22:20:49 +02:00
Sébastien Crozet 6fb6d35980 Documentation fixes. 2014-10-10 20:56:40 +02:00
Sébastien Crozet 924d8269d8 Add points.
This adds the Pnt{1,2,3,4,5,6} structures.
This adds the traits:
  − AnyPnt
  − FloatPnt
  − PntExt
  − FloatPntExt
  − Orig (to return the zero point)
  − PntAsVec
  − VecAsPnt
This adds operator overloading:
  − Pnt + Vec
  − Pnt - Vec
  − Pnt * Scalar
  − Pnt / Scalar
  − Pnt + Scalar
  − Pnt - Scalar
  − Iso * Pnt
  − Rot * Pnt
  − Pnt * Iso
  − Pnt * Rot
This changes some behavior:
  − Iso multiplication with a Vec does not translate the vector any more.
  − ToHomogeneous adds a 0.0 at the end of a Vec and a 1.0 at the end of a Pnt.
  − FromHomogeneous performs w-normalization on a Pnt, but not on a Vec.
  − The Translate<Vec> trait is never implemented (i-e. a Vec is not to be translated).

cc #25
2014-10-10 11:45:20 +02:00
Brendan Zabarauskas b6959ef913 Implement index operators
Closes #18
2014-09-18 12:23:52 +10:00
Sébastien Crozet 5066d6b9de Update to the last rust-nightly.
Version of rustc: 0.11.0-pre-nightly (918dbfe 2014-06-02 20:51:30 -0700).
2014-06-03 22:37:46 +02:00
Sébastien Crozet f6c597f102 Update to the last rust-nightly.
Version of rustc: 0.11.0-pre-nightly (faa7ba7 2014-05-31 01:06:40 -0700).

Main changes:
        * `cmp::Ord` -> `cmp::PartialOrd`
        * `cmp::Eq`  ->  `cmp::PartialEq`

Note that `na::PartialOrd` is not the same as `cmp::PartialOrd`
(which lacks a lot of partial ordering operators).
2014-06-01 15:22:11 +02:00
Franklin Delehelle (Vampire.local) 6468360edb Compile with nightlies 2014-05-21 13:08:04 +02:00
Vincent Barrielle 987b91767a update to the latest rust: FloatMath for math functions (sin/exp/...)
Also removed a bunch of duplicate trait usages
2014-05-16 21:04:35 +02:00
Sébastien Crozet 7ef933aefb Update to the last Rust.
Version of rustc: 0.11-pre (eea4909 2014-04-24 23:41:15 -0700)
Vector do not implement `Rand` anymore.
2014-04-25 20:28:29 +02:00
Sébastien Crozet 06e18d214a Update to the last Rust.
Version of rustc: 0.10-pre (b8ef9fd 2014-03-31 15:51:33 -0700)

struct fields are now public by default.
2014-04-01 23:00:59 +02:00
Sébastien Crozet 1edecbcee4 Automatically derive `TotalEq` whenever `Eq` is derived. 2014-03-28 21:40:30 +01:00
Peter Nguyen 7bc561c835 Update to latest rust.
`std::rand` was moved to it's own crate.
Version of rustc: rustc 0.10-pre (4d64441 2014-03-12 15:07:06 -0700)
2014-03-13 17:47:03 -04:00
Sébastien Crozet 13430866d4 Remove the DeepClone derivings.
Version of rustc: 0.10-pre (e959c87 2014-03-08 22:41:45 -0800)
2014-03-09 10:09:08 +01:00
Sébastien Crozet 57dfc14139 Update to the last Rust.
Version of rustc: 0.10-pre (4243cad 2014-02-24 22:17:02 -0800)
2014-02-25 09:41:41 +01:00
Sébastien Crozet c834439009 Update to the last rust.
Version of rustc: 0.10-pre (a5342d5 2014-02-23 22:06:50 -0800)
2014-02-24 11:48:02 +01:00
Sébastien Crozet ba32051fdf Add deriving `Hash` and `Show`. 2014-02-23 08:44:21 +01:00
Sébastien Crozet becb77843e Update to the last Rust.
Version of rustc: 0.10-pre (b0ce960 2014-02-17 22:16:51 -0800)
This replaces uses of the `Orderable` trait by a `PartialOrd` trait: the `min` and `max` methods
are replaced by `inf` and `sup` methods.
Vectors do not implement the `Ord` trait any more.

Fix #4
2014-02-18 12:13:40 +01:00
Sébastien Crozet f5b0b76d8d Add the ApproxEq trait.
It is no longer part of std::num
2014-01-09 20:48:30 +01:00
Sébastien Crozet 4addd531cf Add incomplete implementation of 4D rotation. 2013-11-22 09:46:48 +01:00
Sébastien Crozet 8423286911 Switch to column-major representation.
Matrices are now column-major.
This will be useful to interop with opengl and lapack.
2013-10-17 22:40:44 +02:00
Sébastien Crozet 90e40aaec0 Make most out-of-place methods static.
This is to make people prefer the functional style.
Things like `a.dot(b)` dont make sense per se (there is no reason for `a` to have a different
status than `b`). Using static methods avoid this.

In-place methods are left unchanged.
2013-10-16 21:44:33 +02:00
Sébastien Crozet ccbc8b4429 Api change: deal with inplace/out of place methods.
Before, it was too easy to use an out of place method instead of the inplace one since they name
were pretty mutch the same. This kind of confusion may lead to silly bugs very hard to understand.
Thus the following changes have been made when a method is available both inplace and out-of-place:

* inplace version keep a short name.
* out-of-place version are suffixed by `_cpy` (meaning `copy`), and are static methods.

Methods applying transformations (rotation, translation or general transform) are now prefixed by
`append`, and a `prepend` version is available too.

Also, free functions doing in-place modifications dont really make sense. They have been removed.

Here are the naming changes:
* `invert` -> `inv`
* `inverted` -> `Inv::inv_cpy`
* `transpose` -> `transpose`
* `transposed` -> `Transpose::transpose_cpy`
* `transform_by` -> `append_transformation`
* `transformed` -> `Transform::append_transformation_cpy`
* `rotate_by` -> `apppend_rotation`
* `rotated` -> `Rotation::append_rotation_cpy`
* `translate_by` -> `apppend_translation`
* `translate` -> `Translation::append_translation_cpy`
* `normalized` -> `Norm::normalize_cpy`
* `rotated_wrt_point` -> `RotationWithTranslation::append_rotation_wrt_point_cpy`
* `rotated_wrt_center` -> `RotationWithTranslation::append_rotation_wrt_center_cpy`

Note that using those static methods is very verbose, and using in-place methods require an
explicit import of the related trait.

This is a way to convince the user to use free functions most of the time.
2013-10-14 10:42:07 +02:00
Sébastien Crozet 7667d8f19a Add a double-trait-dispatch-trick based cast trait
The Cast trait replaces both MatCast and VecCast.
2013-10-09 23:10:43 +02:00
Sébastien Crozet edf17b5667 Update to the last Rust.
Also use free-functions on tests.
2013-10-08 01:22:56 +02:00
Sébastien Crozet 84212f1449 Huge api change!
Everything changed, hopefully for the best.

* everything is accessible from the `na` module. It re-export
  everything and provides free functions (i-e: na::dot(a, b) instead of
  a.dot(b)) for most functionalities.
* matrix/vector adaptors (Rotmat, Transform) are replaced by plain
  types: Rot{2, 3, 4} for rotation matrices and Iso{2, 3, 4} for
  isometries (rotation + translation).  This old adaptors system was to
  hard to understand and to document.
* each file related to data structures moved to the `structs` folder.
  This makes the doc a lot more readable and make people prefer the
  `na` module instead of individual small modules.
* Because `na` exists now, the modules `structs::vec` and
  `structs::mat` dont re-export anything now.

As a side effect, this makes the documentation more readable.
2013-10-06 18:07:17 +02:00