Commit Graph

38 Commits

Author SHA1 Message Date
Sébastien Crozet b244975f93 Update to the last Rust. 2013-11-27 11:24:29 +01:00
Sébastien Crozet bb5654d220 Remove free-functions alliasing structures constructors.
Those constructors are not idiomatic. Use e.g. `Vec3::new(0, 0, 0)` instead.
2013-10-14 11:22:38 +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 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
Sébastien Crozet 514bf74efe "Replaced" Scalar{Add, Sub, Mul, Div} by operator overloading.
Those traits are not really removed since rust cannot handle those multiple operator overloading
very well yet, making them sometimes unuseable on generic code.
2013-09-14 21:32:38 +02:00
Sébastien Crozet 1a08262f50 More unsafe indexing in inner loops and add some benchmarks. 2013-09-14 00:08:46 +02:00
Sébastien Crozet 1cf3506e06 Remove some useless #[test] tags. 2013-09-13 10:34:49 +02:00
Sébastien Crozet bdf82748dc Add a `Dot` and a `Norm` trait for vectors having a dot product and a norm.
Those methods are not part of the `Vec` and `AlgebraicVec` traits any more.
2013-09-08 18:20:06 +02:00
Sébastien Crozet 82ddda154f Update to work with the last compiler.
Because of the unfortunate changes on type parameters resolution:
        - the Dim trait now needs an useless parameter to infer the Self type.
        - ApproxEps::epsilon() is broken.
2013-08-28 14:22:12 +02:00
Sébastien Crozet 347883caa1 Rework of the traits for Vectors.
The goal is to make traits less fine-grained for vectors, and reduce the amount of `use`.

- Scalar{Mul, Div} are removed, replaced by Mul<N, V> and Div<N, V>,
- Ring and DivisionRing are removed. Use Num instead.
- VectorSpace, Dot, and Norm are removed, replaced by the new, higher-level traits.

Add four traits:
- Vec: common operations on vectors. Replaces VectorSpace and Dot.
- AlgebraicVec: Vec + the old Norm trait.
- VecExt: Vec + every other traits vectors implement.
- AlgebraicVecExt: AlgebraicVec + VecExt.
2013-08-18 18:33:25 +02:00
Sébastien Crozet 344d761be5 Add the ability to stop the basis internal itertors. 2013-08-17 10:48:45 +02:00
Sébastien Crozet b08a8384ae Add outer product. 2013-08-12 16:45:31 +02:00
Sébastien Crozet 3858c63291 Update to work with the last Rust api. 2013-08-11 16:07:34 +02:00
Sébastien Crozet c59911168e Fix curly braces. 2013-08-05 10:13:44 +02:00
Sébastien Crozet 53a5dbb6e3 Add `Orderable` implementation for vectors.
The `min`, `max` and `clamp` methods are component-wise.
2013-08-04 11:06:23 +02:00
Sébastien Crozet 9af1cac45d Fix `Ord` implementations to be a partial order.
When two elements are not comparable, all comparison operators return `false`.
2013-08-04 10:36:35 +02:00
Sébastien Crozet 50b34ca765 Fix `for` loops (again) + `iterate` becomes `range`. 2013-08-03 12:21:56 +02:00
Sébastien Crozet 7b2dbb244e Fix `for` loops. 2013-08-02 10:50:04 +02:00
Sébastien Crozet 67dea17abe for ... advance -> foreach ... in 2013-08-01 09:18:21 +02:00
Sébastien Crozet e548e1fa5e Add tests for vec0. 2013-07-20 17:02:54 +02:00
Sébastien Crozet cf216f9b90 Removed occurences of copy/Copy + improved api.
Now, access to vector components are x, y, z, w, a, b, ... instead of at[i].
The method at(i) has the same (read only) effect as the old at[i].

Now, access to matrix components are m11, m12, ... instead of mij[offset(i, j)]...
The method at((i, j)) has the same effect as the old mij[offset(i, j)].

Automatic implementation of all traits the compiler supports has been added on the #[deriving]
clause for both matrices and vectors.
2013-07-20 15:07:49 +02:00
Sébastien Crozet 68d601a642 Basis trait now uses internal iterators to avoid allocations. 2013-07-01 16:33:22 +00:00
Sébastien Crozet c58e1ed40d Reorganized files. 2013-06-29 00:34:45 +00:00
Sébastien Crozet cd355dfb30 Refactor vec{1, 2, 3} implemenation + add some useful traits. 2013-06-28 21:03:40 +00:00
Sébastien Crozet 0a90e6e6d8 all -> iter().all 2013-06-23 16:19:13 +00:00
Sébastien Crozet cfd7bac305 Fix to make it work with the new compiler. 2013-06-19 12:26:59 +02:00
Sébastien Crozet 513d4d7b08 Add inlining pragmas. 2013-06-13 16:48:28 +00:00
Sébastien Crozet 4c65f793e8 Add flatten trait. 2013-06-10 00:09:36 +00:00
Sébastien Crozet bd5f1eae88 Codding style fix. 2013-06-09 14:04:54 +00:00
Sébastien Crozet ffc24de9e0 Removed useless iterator usage. 2013-06-09 12:12:18 +00:00
Sébastien Crozet 965601d4e0 Adapted to new vec iterator api. 2013-06-09 12:09:22 +00:00
Sébastien Crozet 0b8058e88f Adapted for the compiler 'incomming' branch. 2013-06-01 20:50:00 +02:00
Sébastien Crozet 65b175b4a7 Refactored tests using macros. 2013-05-21 23:15:20 +00:00
Sébastien Crozet 3fa933d13f Add comments and adapted to new rust syntax. 2013-05-21 22:46:33 +00:00
Sébastien Crozet a0ada142a6 Removed useless use on the .rc. 2013-05-18 21:56:03 +00:00
Sébastien Crozet 931f2e2b80 Removed useless loops on basis test. 2013-05-18 17:07:38 +00:00
Sébastien Crozet 890cdb73f2 Add tests and basis generation. 2013-05-18 17:04:03 +00:00