Commit Graph

1465 Commits

Author SHA1 Message Date
Sébastien Crozet b61d621090 Update to the last Rust. 2013-09-26 17:05:11 +02:00
Sébastien Crozet 410bbd1d25 Update to the last Rust api.
RngUtils is dead.
rustdoc_ng became rustdoc.
2013-09-22 21:12:50 +02:00
Sébastien Crozet 4ffe274b03 Add mean and covariance computation for DMat.
This also fixes the transposition for rectangular DMat, and add scalar
addition/subtraction/multiplication/division for DMat.
2013-09-22 15:47:53 +02:00
Sébastien Crozet 7de844b46a Moved some files + use rustdoc_ng to generate the documenatiton.
Trait failes are merged in three files:
    * operations.rs - for low-level matrix/vector operations
    * geometry.rs   - for operations with a clear, broadly known geometric meaning.
    * structure.rs  - for operations to access/alter the object inner structures.

Specialisations are moved to the `spec` folder.
2013-09-22 11:05:15 +02:00
Sébastien Crozet 9a9de20b8a Remove the redundant `Column` trait + Add unchecked access indexing to dynamic matrices/vectors. 2013-09-20 22:17:55 +02:00
Sébastien Crozet c89a6681c1 Fix broken 2d rotation. 2013-09-15 11:51:42 +02:00
Sébastien Crozet 6dc8139794 "Remove" the RMul and LMul trait. Use the regular Mul trait.
Those traits are not really removed since they are useful on generic code (to work around curret
limitations of rust traits system).
2013-09-15 11:18:06 +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 e3a1d56e58 Set up the hack to allow better overloads of the Mul trait.
This is strongly inpired by
http://smallcultfollowing.com/babysteps/blog/2012/10/04/refining-traits-slash-impls/
2013-09-14 17:08:48 +02:00
Sébastien Crozet 06c7293e83 Specialized Mul, RMul, and LMul for Mat2 and Mat3. 2013-09-14 11:07:52 +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 72395f3546 Add an unsafe `at_fast` method for unchecked read access to DVec and DMat. 2013-09-13 11:32:30 +02:00
Sébastien Crozet 3b814b462f Add unsafe methods to initialize a DVec or DMat without initialization. 2013-09-13 11:11:04 +02:00
Sébastien Crozet 05470bba90 Add a `new_random` method to build a `DMat` or `DVec` filled with random numbers. 2013-09-13 10:56:25 +02:00
Sébastien Crozet 1cf3506e06 Remove some useless #[test] tags. 2013-09-13 10:34:49 +02:00
Sébastien Crozet 6f81fc6d5c Add `Absolute`, `Col`, `Mat`, `AbsoluteRotate` traits.
Traits like `AbsoluteRotate` and `RotationWithTranslation` have been moved to a `comp` folder
containing any trait providing operations which are combination of several traits.
2013-09-13 10:26:19 +02:00
Sébastien Crozet 00f26f8951 Replace std::iterator by std::iter. 2013-09-09 11:19:54 +02:00
Sébastien Crozet ea98ef15b7 Implement `Norm` and `Dot` for `DVec`. 2013-09-08 18:29:51 +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 37f0b123e0 Make the dot-product and normalization related methods public for DVec.
This will change soon with two traits: Dot and Norm.
2013-09-08 18:00:28 +02:00
Sébastien Crozet 992adb99f0 Add a `Container` implementation for every vector. 2013-09-08 17:26:31 +02:00
Sébastien Crozet 57b89b38df Add `nrow()`, `ncols()` methods for `DMat`, and Container impl. for `DVec`. 2013-09-08 17:19:50 +02:00
Sébastien Crozet 3ab06faef6 Implement `UnitSphereSample` for `Vec1`. 2013-09-08 16:03:03 +02:00
Sébastien Crozet 6147d5424e Implement 3d rotation matrix -> axis angle conversion.
Cornercases are not handled correctly yet.
2013-09-08 15:45:32 +02:00
Sébastien Crozet 4e33b96aec Update to the last rust. 2013-09-07 17:26:05 +02:00
Sébastien Crozet 8db01c6409 Add more functions to initialize DMat and DVec. 2013-09-07 08:43:17 +02:00
Sébastien Crozet a00860df41 Reexport `DMat` in mat.rs and `DVec` in vec.rs. 2013-09-07 08:23:09 +02:00
Sébastien Crozet 0be1132452 Swap the type parameters of `Transform`. 2013-09-06 15:22:14 +02:00
Sébastien Crozet 2ccd62d558 Add methods to set the translation/rotation/transformation directly. 2013-09-06 08:48:08 +02:00
Sébastien Crozet a0b232be0a Rename `Mat4::projection` to `mat4::new_perspective`. 2013-09-05 13:45:11 +02:00
Sébastien Crozet 628066cdc8 Make DMat able to represent rectangular matrices.
The code is largely untested.
2013-09-05 00:01:52 +02:00
Sébastien Crozet 8973e0d67c Add function to create a projection matrix. 2013-09-04 23:29:58 +02:00
Sébastien Crozet 539e34c2bf Move all the rotation-related free functions to a `RotationWithTranslation` trait.
This is not a very good name though.
2013-09-04 17:07:56 +02:00
Sébastien Crozet 70cee0ea3d Rename the main module lib.rs.
This is a first step toward the use of rustpkg.
2013-08-31 18:33:20 +02:00
Sébastien Crozet a40899ef67 Add missing rotation-related functions. 2013-08-31 17:17:18 +02:00
Sébastien Crozet 9ecafc5cdf Dont use globing `pub use`, they are buggy. 2013-08-31 17:14:41 +02:00
Sébastien Crozet f762891ecf Move the `Outer` product trait to vec.rs 2013-08-31 12:23:26 +02:00
Sébastien Crozet a5a616e05e Make the `traits` module private.
Use `vec::Whatever` or `mat::Whatever` instead of `traits::whatever::Whatever`.
2013-08-31 12:16:53 +02:00
Sébastien Crozet 1b31304a9e Rework the trait exports.
`use vec::an_operation` will import a vector-applicable operation trait.
`use mat::an_operation` will import a matrix-applicable operation trait.
2013-08-31 11:41:32 +02:00
Sébastien Crozet eb4e4a6aeb Add a PVec3 type, for Padded Vector 3d.
This is the same as Vec3 but with an extra field for padding. This is useful for applications
needing a power-of-two number of arguments (typically mixed CPU/GPU applications).

The corresponding matrix is not yet implemented.
2013-08-31 11:13:17 +02:00
Sébastien Crozet 346a803b7f Improve how the dummy parameter are passed to the Dim::dim function. 2013-08-30 09:53:17 +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 f465928085 Fix Transform adaptor ToHomogeneous implementation. 2013-08-26 17:39:25 +02:00
Sébastien Crozet 7052aa88ee Add two traits: `CrossMatrix` and `Row`.
CrossMatrix is a trait for vectors having a cross product representable as a matrix.
Row is a trait for Matrixces and Vectors, to access (by index) their rows.
2013-08-25 23:01:44 +02:00
Sébastien Crozet 4635d6ebac Add Rotate, Transform, Translate impl for vectors. 2013-08-23 16:29:08 +02:00
Sébastien Crozet 833378d83f Add and `Identity` matrix type.
It implements most matrix traits but all its operations are no-ops.
2013-08-23 15:59:26 +02:00
Sébastien Crozet 6999444575 Merge the Rotatable, Translatable, Transformable traits with their corresponding Rotation, Translation, Transformation. 2013-08-22 17:47:37 +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 cead4f8410 Moved DivisionRing to ring.rs. 2013-08-17 17:50:01 +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 d8db04cce5 Changed the UniformSphereSample trait to return a borrowed vector. 2013-08-16 18:08:51 +02:00
Sébastien Crozet 61e985634b Fix FromIterator impl. 2013-08-16 10:14:01 +02:00
Sébastien Crozet 5187a1a73f Add `Round` impl for vectors. 2013-08-15 10:41:47 +02:00
Sébastien Crozet a69f43bccd Remove some unneded visibility modifiers. 2013-08-14 09:43:02 +02:00
Sébastien Crozet 24e1862a9e Fix to work with the last Rust deriving. 2013-08-13 10:57:19 +02:00
Sébastien Crozet a46b063192 Add Scalar{Mul, Div, Add, Sub} for matrices. 2013-08-12 17:04:53 +02:00
Sébastien Crozet 037cf95542 Add (pointwise) Add and Sub impl for matrices. 2013-08-12 16:50:50 +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 50a6454ae8 Add missing #[inline] hints. 2013-08-07 20:53:51 +02:00
Sébastien Crozet efd14f9e88 Further coding style fixes. 2013-08-05 10:15:11 +02:00
Sébastien Crozet c59911168e Fix curly braces. 2013-08-05 10:13:44 +02:00
Sébastien Crozet a810bf6008 Indentation fixes. 2013-08-05 09:44:56 +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 3f3f59e8eb Changed mod visibilities + add doc for types.rs 2013-08-01 18:55:42 +02:00
Sébastien Crozet 67dea17abe for ... advance -> foreach ... in 2013-08-01 09:18:21 +02:00
Sébastien Crozet 164ff5b1b2 Add missing type bounds. 2013-07-25 14:50:55 +02:00
Sébastien Crozet 4f3de703b7 Add static methods to build canonical axis.
For exemple use: Vec3::x() to create the vector Vec3::new(1.0, 0.0, 0.0).
The same aplies for y, z, w, etc.
2013-07-24 23:54:54 +02:00
Sébastien Crozet e75fe80966 Add documentation. 2013-07-24 16:50:40 +02:00
Sébastien Crozet 6cf8db0926 Replaced all remaining ocurences of from_homogeneous by from 2013-07-23 23:28:02 +02:00
Sébastien Crozet 321574a827 from_homogeneous -> from 2013-07-23 23:26:47 +02:00
Sébastien Crozet 93597f0ef9 Add look_at_z.
Having a look_at which aligns the z-axis with the look_at direction is useful for cameras. It
will exist only in 3d.
2013-07-23 18:41:57 +02:00
Sébastien Crozet 8634b9037d Changed the semantic of the look_at method.
Before, the `look_at` method aligned the `z` axis with the look_at direction.
This will be problematic in the future if we want to generalize that on n-dimension (the z axis
could not axis at all when n < 3).
Now, the `look_at` method aligns the `x` axis with the look_at direction. Thus we have a chance for
it to be generalizable on n-dimension, `n >= 1`.
2013-07-23 12:12:03 +02:00
Sébastien Crozet 4ea1dd92e6 Fixed transposition. 2013-07-23 11:15:20 +02:00
Sébastien Crozet cd2aeb4861 Fix look_at. 2013-07-23 01:06:20 +02:00
Sébastien Crozet e2f34023ed Add traits MatCast and VecCast.
VecCast casts a Vec<N1> to a Vec<N2> with N1 and N2 bounded by NumCast.
MatCast casts a Mat<N1> to a Mat<N2> with N1 and N2 bounded by NumCast.
2013-07-22 23:42:35 +02:00
Sébastien Crozet 81389a911a Add utility methods.
Added look_at for 3d rotation matrix and 3d transform.
Rotation matrices constructors are now the static methods Rotmat::from_angle,
Rotmat::from_axis_angle.
2013-07-22 23:20:03 +02:00
Sébastien Crozet 0577f3e364 Add type aliases. 2013-07-22 13:44:08 +02:00
Sébastien Crozet f92b28f53f Add sphere sampling implementation for Vec3<f64>. 2013-07-22 12:32:42 +02:00
Sébastien Crozet 3a64e05c62 Merged the {vec, mat} and {vec, mat}_impl modules. 2013-07-22 11:35:36 +02:00
Sébastien Crozet ff24f70332 Flattened the `traits` submodules. 2013-07-22 10:26:20 +02:00
Sébastien Crozet e548e1fa5e Add tests for vec0. 2013-07-20 17:02:54 +02:00
Sébastien Crozet ae74a05fdd Add implementation of Vec0. 2013-07-20 16:32:39 +02:00
Sébastien Crozet d74a5905c6 Fix sub_dot implementations. 2013-07-20 15:18:44 +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 8918cb5d7e invert -> inplace_inverse to avoid name clash with iterators. 2013-07-13 13:34:41 +00:00
Sébastien Crozet 7f05cc5977 abs needs the Signed trait. 2013-07-10 17:43:45 +00:00
Sébastien Crozet c37d58f3fb Add Vec0. 2013-07-07 22:34:18 +02:00
Sébastien Crozet 831f561441 Use Clone instead of Copy. 2013-07-05 22:54:42 +00:00
Sébastien Crozet 6f081b70b8 Add sphere sempling trait + Copy becomes Clone 2013-07-04 14:23:08 +00:00
Sébastien Crozet 51fd2bc744 map -> iter().transform 2013-07-02 10:00:55 +00: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 6fd9696253 Fix bug when trying to create a rotation matrix with a zero angle. 2013-06-30 21:19:36 +00:00
Sébastien Crozet 02e22717a4 More rotation sugar. 2013-06-29 19:02:51 +00:00
Sébastien Crozet f8515f4683 Add rotation wrt center of a matrix. 2013-06-29 18:59:04 +00:00
Sébastien Crozet 50293ca417 Add read-only access to a Rotmat subcomponents. 2013-06-29 18:37:01 +00:00
Sébastien Crozet 364c16ca19 Add read-only accesse to a Transform subcomponents. 2013-06-29 18:35:01 +00:00
Sébastien Crozet 50d424a901 Changed the representation of rotations for 3D matrix. 2013-06-29 15:32:56 +00:00
Sébastien Crozet 429bcbf9c3 Fix Column implementation generating an ICE. 2013-06-29 15:19:21 +00:00
Sébastien Crozet d3bed841f8 Add Column implementations. 2013-06-29 15:04:38 +00:00
Sébastien Crozet 8e8a87b667 Fixes to work with the new compiler. 2013-06-29 12:06:39 +00:00
Sébastien Crozet 3bb470ac95 Add Column + Homogeneous + Indexable traits.
Column: to access a matrix column.
Homogeneous: to convert a matrix/vector from/to homogenous coordinates.
Indexable: to access a matrix/vector element using indices.
2013-06-29 11:40:31 +00:00
Sébastien Crozet c58e1ed40d Reorganized files. 2013-06-29 00:34:45 +00:00
Sébastien Crozet c54eb562ec Refactor code for matrices. 2013-06-28 22:55:09 +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 8abcdeeedc #[inline(always)] -> #[inline] 2013-06-27 17:40:37 +00:00
Sébastien Crozet 6723693b49 Refined traits for rotation/translation/transformation. 2013-06-27 16:16:07 +00:00
Sébastien Crozet ffbcf4882a Removed a lot of Copy + made Rotation and Translation more flexible. 2013-06-26 20:56:30 +00:00
Sébastien Crozet edc5bb616d Removed some useless references. 2013-06-24 21:38:52 +00:00
Sébastien Crozet 870f4b804b Fix some infinite recursion on nvec. 2013-06-23 20:16:15 +00:00
Sébastien Crozet 0a90e6e6d8 all -> iter().all 2013-06-23 16:19:13 +00:00
Sébastien Crozet 8dc9067121 Coding style fix. 2013-06-23 16:08:50 +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 854dda73bf Add implementation of Bounded. 2013-06-15 22:11:33 +00:00
Sébastien Crozet caee7eb423 workarounds -> traits. All ICE are now compiler errors. 2013-06-15 20:16:44 +00:00
Sébastien Crozet 6e627f3378 Add Ord instances. 2013-06-15 18:06:13 +00:00
Sébastien Crozet 513d4d7b08 Add inlining pragmas. 2013-06-13 16:48:28 +00:00
Sébastien Crozet 4cc5b178c8 Add DeltaTransformVector tait and fix transformation. 2013-06-13 14:44:15 +00:00
Sébastien Crozet fb20ffdf8b Add automatic implementation of VectorSpace. 2013-06-11 11:03:16 +02:00
Sébastien Crozet 53486fe614 Changed flattening function names. 2013-06-10 09:46:42 +02:00
Sébastien Crozet 4c65f793e8 Add flatten trait. 2013-06-10 00:09:36 +00:00
Sébastien Crozet c02edb9d09 Used a better type parametter name. 2013-06-09 23:36:47 +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 ec87e81426 Relaxed type constraints for transform rotation. 2013-06-08 16:33:49 +00:00
Sébastien Crozet 8a1b81f839 Primitive construction is more idiomatique using new. 2013-06-08 10:09:17 +00:00
Sébastien Crozet e9948f55d0 Add rotation wrt a point. 2013-06-06 22:57:07 +00:00
Sébastien Crozet 0b8058e88f Adapted for the compiler 'incomming' branch. 2013-06-01 20:50:00 +02:00
Sébastien Crozet 4146385e09 Fix matrix inversion algorithm. 2013-05-31 18:35:48 +02:00
Sébastien Crozet f264b75ce6 Add dynamically sized matrix. 2013-05-31 11:28:42 +02:00
Sébastien Crozet 335794208d Add dynamically sized vector. 2013-05-31 11:01:07 +02:00
Sébastien Crozet a77013e4c7 Use automatic ToStr deriving for everything. 2013-05-25 18:30:03 +00:00
Sébastien Crozet 898a87b46c Add SubDot trait and basic implementations. 2013-05-25 13:51:51 +00:00
Sébastien Crozet 2b9dc1d2e3 Fix comment. 2013-05-21 23:20:09 +00: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 4312daa53c Removed the triginometric trait workaround. 2013-05-20 10:02:02 +00:00
Sébastien Crozet b2d17300d9 Add delta-transformation implementations. 2013-05-19 19:45:30 +00:00
Sébastien Crozet f3ed302874 Add delta-transformation. 2013-05-19 19:45:04 +00:00
Sébastien Crozet ec160e5219 Fix rotation for transform adaptor. 2013-05-19 15:01:38 +00:00
Sébastien Crozet 52a769a431 Add a test for the 2d rotation. 2013-05-19 11:53:19 +00:00
Sébastien Crozet dc0757b2e5 Add rotation and translation traits. 2013-05-19 11:44:27 +00:00
Sébastien Crozet a0ada142a6 Removed useless use on the .rc. 2013-05-18 21:56:03 +00:00
Sébastien Crozet ceed733e25 Functions to build objects dont shadow constructors any more. 2013-05-18 20:03:45 +00:00
Sébastien Crozet 01d37a1b56 Refined ScalaOp trait. 2013-05-18 18:06:36 +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
Sébastien Crozet 39707b42dc Add rand for nvec. 2013-05-18 15:03:54 +00:00
Sébastien Crozet 622435f7ad Add Rand for nmat. 2013-05-18 11:38:56 +00:00
Sébastien Crozet 98b484c311 Fix readme for workarounds. 2013-05-17 22:13:07 +00:00
Sébastien Crozet bc93c44206 Add Rand implementation for everything. 2013-05-18 00:11:59 +00:00
Sébastien Crozet 53131731b3 Add fuzzy_eq implementation for everything. 2013-05-16 22:23:25 +00:00
Sébastien Crozet 7a58f2c66a Add comments for traits. 2013-05-16 21:59:41 +00:00
Sébastien Crozet 699e4c5bb7 Adapted assertions with last rust zero-testing api. 2013-05-16 21:44:05 +00:00
Sébastien Crozet e11cbb0963 Add one-dimensional primitives. 2013-05-16 21:43:14 +00:00
Sébastien Crozet d636fdd346 Add matrix adaptors and addapted to the now rust features. 2013-05-16 21:30:39 +00:00
Sébastien Crozet c7059af99d Fix 2d matrix multiplication and 3d matrix inversion. 2013-05-15 11:51:53 +02:00
Sébastien Crozet cfe636c11b Replaced an uggly for by a bit less uggly while for the matrix inversion. 2013-05-15 01:10:18 +00:00
Sébastien Crozet 30d82f2408 Add n-dimensional vector and matrix. 2013-05-15 00:18:13 +00:00
Sébastien Crozet 4582492fda Addesome traits and configuration file. 2013-05-14 21:08:29 +00:00
Sébastien Crozet 8b18310c3c Add basic operations. 2013-05-14 11:35:01 +00:00