Changed mod visibilities + add doc for types.rs

This commit is contained in:
Sébastien Crozet 2013-08-01 18:55:42 +02:00
parent 67dea17abe
commit 3f3f59e8eb
4 changed files with 156 additions and 67 deletions

View File

@ -52,7 +52,7 @@ impl<N, Iter: Iterator<N>> FromIterator<N, Iter> for DVec<N>
{ {
let mut res = DVec { at: ~[] }; let mut res = DVec { at: ~[] };
for param.advance |e| foreach e in param
{ res.at.push(e) } { res.at.push(e) }
res res

View File

@ -17,15 +17,15 @@
extern mod std; extern mod std;
extern mod extra; extern mod extra;
mod dmat; pub mod dmat;
mod dvec; pub mod dvec;
pub mod vec; pub mod vec;
pub mod mat; pub mod mat;
// specialization for some 1d, 2d and 3d operations // specialization for some 1d, 2d and 3d operations
pub mod mat_spec; mod mat_spec;
pub mod vec_spec; mod vec_spec;
pub mod vec0_spec; mod vec0_spec;
/// Wrappers around raw matrices to restrict their behaviour. /// Wrappers around raw matrices to restrict their behaviour.
pub mod adaptors pub mod adaptors
@ -36,41 +36,40 @@ pub mod adaptors
pub mod types; pub mod types;
pub mod num // pub mod num
{ // {
pub use traits::dim::*; // pub use traits::dim::*;
pub use traits::homogeneous::*; // pub use traits::homogeneous::*;
pub use traits::ring::*; // pub use traits::ring::*;
pub use traits::division_ring::*; // pub use traits::division_ring::*;
} // }
// FIXME: it would be better to hide all those from the outside! // FIXME: it would be better to hide all those from the outside!
/// Useful linear-algebra related traits. pub mod traits
mod traits
{ {
mod sample; pub mod sample;
mod indexable; pub mod indexable;
mod column; pub mod column;
mod iterable; pub mod iterable;
mod dot; pub mod dot;
mod cross; pub mod cross;
mod inv; pub mod inv;
mod transpose; pub mod transpose;
mod dim; pub mod dim;
mod basis; pub mod basis;
mod norm; pub mod norm;
mod rotation; pub mod rotation;
mod translation; pub mod translation;
mod transformation; pub mod transformation;
mod vector_space; pub mod vector_space;
mod ring; pub mod ring;
mod division_ring; pub mod division_ring;
mod sub_dot; pub mod sub_dot;
mod rlmul; pub mod rlmul;
mod scalar_op; pub mod scalar_op;
mod homogeneous; pub mod homogeneous;
mod vec_cast; pub mod vec_cast;
mod mat_cast; pub mod mat_cast;
} }
#[cfg(test)] #[cfg(test)]

View File

@ -4,127 +4,217 @@ use adaptors::rotmat::Rotmat;
use adaptors::transform::Transform; use adaptors::transform::Transform;
// 1D // 1D
/// 1-dimensional `f64`-valued vector.
pub type Vec1f64 = Vec1<f64>; pub type Vec1f64 = Vec1<f64>;
/// 1-dimensional `f32`-valued vector.
pub type Vec1f32 = Vec1<f32>; pub type Vec1f32 = Vec1<f32>;
/// 1-dimensional `float`-valued vector.
pub type Vec1flt = Vec1<float>; pub type Vec1flt = Vec1<float>;
/// 1-dimensional `f64`-valued matrix.
pub type Mat1f64 = Mat1<f64>; pub type Mat1f64 = Mat1<f64>;
/// 1-dimensional `f32`-valued matrix.
pub type Mat1f32 = Mat1<f32>; pub type Mat1f32 = Mat1<f32>;
/// 1-dimensional `float`-valued matrix.
pub type Mat1flt = Mat1<float>; pub type Mat1flt = Mat1<float>;
pub type Rot1f64 = Rotmat<Mat1<f64>>; // /// 1-dimensional `f64`-valued rotation matrix.
pub type Rot1f32 = Rotmat<Mat1<f32>>; // pub type Rot1f64 = Rotmat<Mat1<f64>>;
pub type Rot1flt = Rotmat<Mat1<float>>; // /// 1-dimensional `f32`-valued rotation matrix.
// pub type Rot1f32 = Rotmat<Mat1<f32>>;
pub type Iso1f64 = Transform<Rot1f64, Vec1f64>; // /// 1-dimensional `float`-valued rotation matrix.
pub type Iso1f32 = Transform<Rot1f32, Vec1f32>; // pub type Rot1flt = Rotmat<Mat1<float>>;
pub type Iso1flt = Transform<Rot1flt, Vec1flt>; //
// /// 1-dimensional `f64`-valued isometric transform.
// pub type Iso1f64 = Transform<Rot1f64, Vec1f64>;
// /// 1-dimensional `f32`-valued isometric transform.
// pub type Iso1f32 = Transform<Rot1f32, Vec1f32>;
// /// 1-dimensional `float`-valued isometric transform.
// pub type Iso1flt = Transform<Rot1flt, Vec1flt>;
/// 1-dimensional `f64`-valued general transform.
pub type Aff1f64 = Transform<Mat1f64, Vec1f64>; pub type Aff1f64 = Transform<Mat1f64, Vec1f64>;
/// 1-dimensional `f32`-valued general transform.
pub type Aff1f32 = Transform<Mat1f32, Vec1f32>; pub type Aff1f32 = Transform<Mat1f32, Vec1f32>;
/// 1-dimensional `float`-valued general transform.
pub type Aff1flt = Transform<Mat1flt, Vec1flt>; pub type Aff1flt = Transform<Mat1flt, Vec1flt>;
// 2D // 2D
/// 2-dimensional `f64`-valued vector.
pub type Vec2f64 = Vec2<f64>; pub type Vec2f64 = Vec2<f64>;
/// 2-dimensional `f32`-valued vector.
pub type Vec2f32 = Vec2<f32>; pub type Vec2f32 = Vec2<f32>;
/// 2-dimensional `float`-valued vector.
pub type Vec2flt = Vec2<float>; pub type Vec2flt = Vec2<float>;
/// 2-dimensional `f64`-valued matrix.
pub type Mat2f64 = Mat2<f64>; pub type Mat2f64 = Mat2<f64>;
/// 2-dimensional `f32`-valued matrix.
pub type Mat2f32 = Mat2<f32>; pub type Mat2f32 = Mat2<f32>;
/// 2-dimensional `float`-valued matrix.
pub type Mat2flt = Mat2<float>; pub type Mat2flt = Mat2<float>;
/// 2-dimensional `f64`-valued rotation matrix.
pub type Rot2f64 = Rotmat<Mat2<f64>>; pub type Rot2f64 = Rotmat<Mat2<f64>>;
/// 2-dimensional `f32`-valued rotation matrix.
pub type Rot2f32 = Rotmat<Mat2<f32>>; pub type Rot2f32 = Rotmat<Mat2<f32>>;
/// 2-dimensional `float`-valued rotation matrix.
pub type Rot2flt = Rotmat<Mat2<float>>; pub type Rot2flt = Rotmat<Mat2<float>>;
/// 2-dimensional `f64`-valued isometric transform.
pub type Iso2f64 = Transform<Rot2f64, Vec2f64>; pub type Iso2f64 = Transform<Rot2f64, Vec2f64>;
/// 2-dimensional `f32`-valued isometric transform.
pub type Iso2f32 = Transform<Rot2f32, Vec2f32>; pub type Iso2f32 = Transform<Rot2f32, Vec2f32>;
/// 2-dimensional `float`-valued isometric transform.
pub type Iso2flt = Transform<Rot2flt, Vec2flt>; pub type Iso2flt = Transform<Rot2flt, Vec2flt>;
/// 2-dimensional `f64`-valued general transform.
pub type Aff2f64 = Transform<Mat2f64, Vec2f64>; pub type Aff2f64 = Transform<Mat2f64, Vec2f64>;
/// 2-dimensional `f32`-valued general transform.
pub type Aff2f32 = Transform<Mat2f32, Vec2f32>; pub type Aff2f32 = Transform<Mat2f32, Vec2f32>;
/// 2-dimensional `float`-valued general transform.
pub type Aff2flt = Transform<Mat2flt, Vec2flt>; pub type Aff2flt = Transform<Mat2flt, Vec2flt>;
// 3D // 3D
/// 3-dimensional `f64`-valued vector.
pub type Vec3f64 = Vec3<f64>; pub type Vec3f64 = Vec3<f64>;
/// 3-dimensional `f32`-valued vector.
pub type Vec3f32 = Vec3<f32>; pub type Vec3f32 = Vec3<f32>;
/// 3-dimensional `float`-valued vector.
pub type Vec3flt = Vec3<float>; pub type Vec3flt = Vec3<float>;
/// 3-dimensional `f64`-valued matrix.
pub type Mat3f64 = Mat3<f64>; pub type Mat3f64 = Mat3<f64>;
/// 3-dimensional `f32`-valued matrix.
pub type Mat3f32 = Mat3<f32>; pub type Mat3f32 = Mat3<f32>;
/// 3-dimensional `float`-valued matrix.
pub type Mat3flt = Mat3<float>; pub type Mat3flt = Mat3<float>;
/// 3-dimensional `f64`-valued rotation matrix.
pub type Rot3f64 = Rotmat<Mat3<f64>>; pub type Rot3f64 = Rotmat<Mat3<f64>>;
/// 3-dimensional `f32`-valued rotation matrix.
pub type Rot3f32 = Rotmat<Mat3<f32>>; pub type Rot3f32 = Rotmat<Mat3<f32>>;
/// 3-dimensional `float`-valued rotation matrix.
pub type Rot3flt = Rotmat<Mat3<float>>; pub type Rot3flt = Rotmat<Mat3<float>>;
/// 3-dimensional `f64`-valued isometric transform.
pub type Iso3f64 = Transform<Rot3f64, Vec3f64>; pub type Iso3f64 = Transform<Rot3f64, Vec3f64>;
/// 3-dimensional `f32`-valued isometric transform.
pub type Iso3f32 = Transform<Rot3f32, Vec3f32>; pub type Iso3f32 = Transform<Rot3f32, Vec3f32>;
/// 3-dimensional `float`-valued isometric transform.
pub type Iso3flt = Transform<Rot3flt, Vec3flt>; pub type Iso3flt = Transform<Rot3flt, Vec3flt>;
/// 3-dimensional `f64`-valued general transform.
pub type Aff3f64 = Transform<Mat3f64, Vec3f64>; pub type Aff3f64 = Transform<Mat3f64, Vec3f64>;
/// 3-dimensional `f32`-valued general transform.
pub type Aff3f32 = Transform<Mat3f32, Vec3f32>; pub type Aff3f32 = Transform<Mat3f32, Vec3f32>;
/// 3-dimensional `float`-valued general transform.
pub type Aff3flt = Transform<Mat3flt, Vec3flt>; pub type Aff3flt = Transform<Mat3flt, Vec3flt>;
// 4D // 4D
/// 4-dimensional `f64`-valued vector.
pub type Vec4f64 = Vec4<f64>; pub type Vec4f64 = Vec4<f64>;
/// 4-dimensional `f32`-valued vector.
pub type Vec4f32 = Vec4<f32>; pub type Vec4f32 = Vec4<f32>;
/// 4-dimensional `float`-valued vector.
pub type Vec4flt = Vec4<float>; pub type Vec4flt = Vec4<float>;
/// 4-dimensional `f64`-valued matrix.
pub type Mat4f64 = Mat4<f64>; pub type Mat4f64 = Mat4<f64>;
/// 4-dimensional `f32`-valued matrix.
pub type Mat4f32 = Mat4<f32>; pub type Mat4f32 = Mat4<f32>;
/// 4-dimensional `float`-valued matrix.
pub type Mat4flt = Mat4<float>; pub type Mat4flt = Mat4<float>;
pub type Rot4f64 = Rotmat<Mat4<f64>>; // /// 4-dimensional `f64`-valued rotation matrix.
pub type Rot4f32 = Rotmat<Mat4<f32>>; // pub type Rot4f64 = Rotmat<Mat4<f64>>;
pub type Rot4flt = Rotmat<Mat4<float>>; // /// 4-dimensional `f32`-valued rotation matrix.
// pub type Rot4f32 = Rotmat<Mat4<f32>>;
pub type Iso4f64 = Transform<Rot4f64, Vec4f64>; // /// 4-dimensional `float`-valued rotation matrix.
pub type Iso4f32 = Transform<Rot4f32, Vec4f32>; // pub type Rot4flt = Rotmat<Mat4<float>>;
pub type Iso4flt = Transform<Rot4flt, Vec4flt>; //
// /// 4-dimensional `f64`-valued isometric transform.
// pub type Iso4f64 = Transform<Rot4f64, Vec4f64>;
// /// 4-dimensional `f32`-valued isometric transform.
// pub type Iso4f32 = Transform<Rot4f32, Vec4f32>;
// /// 4-dimensional `float`-valued isometric transform.
// pub type Iso4flt = Transform<Rot4flt, Vec4flt>;
/// 4-dimensional `f64`-valued general transform.
pub type Aff4f64 = Transform<Mat4f64, Vec4f64>; pub type Aff4f64 = Transform<Mat4f64, Vec4f64>;
/// 4-dimensional `f32`-valued general transform.
pub type Aff4f32 = Transform<Mat4f32, Vec4f32>; pub type Aff4f32 = Transform<Mat4f32, Vec4f32>;
/// 4-dimensional `float`-valued general transform.
pub type Aff4flt = Transform<Mat4flt, Vec4flt>; pub type Aff4flt = Transform<Mat4flt, Vec4flt>;
// 5D // 5D
/// 5-dimensional `f64`-valued vector.
pub type Vec5f64 = Vec5<f64>; pub type Vec5f64 = Vec5<f64>;
/// 5-dimensional `f32`-valued vector.
pub type Vec5f32 = Vec5<f32>; pub type Vec5f32 = Vec5<f32>;
/// 5-dimensional `float`-valued vector.
pub type Vec5flt = Vec5<float>; pub type Vec5flt = Vec5<float>;
/// 5-dimensional `f64`-valued matrix.
pub type Mat5f64 = Mat5<f64>; pub type Mat5f64 = Mat5<f64>;
/// 5-dimensional `f32`-valued matrix.
pub type Mat5f32 = Mat5<f32>; pub type Mat5f32 = Mat5<f32>;
/// 5-dimensional `float`-valued matrix.
pub type Mat5flt = Mat5<float>; pub type Mat5flt = Mat5<float>;
pub type Rot5f64 = Rotmat<Mat5<f64>>; // /// 5-dimensional `f64`-valued rotation matrix.
pub type Rot5f32 = Rotmat<Mat5<f32>>; // pub type Rot5f64 = Rotmat<Mat5<f64>>;
pub type Rot5flt = Rotmat<Mat5<float>>; // /// 5-dimensional `f32`-valued rotation matrix.
// pub type Rot5f32 = Rotmat<Mat5<f32>>;
pub type Iso5f64 = Transform<Rot5f64, Vec5f64>; // /// 5-dimensional `float`-valued rotation matrix.
pub type Iso5f32 = Transform<Rot5f32, Vec5f32>; // pub type Rot5flt = Rotmat<Mat5<float>>;
pub type Iso5flt = Transform<Rot5flt, Vec5flt>; //
// /// 5-dimensional `f64`-valued isometric transform.
// pub type Iso5f64 = Transform<Rot5f64, Vec5f64>;
// /// 5-dimensional `f32`-valued isometric transform.
// pub type Iso5f32 = Transform<Rot5f32, Vec5f32>;
// /// 5-dimensional `float`-valued isometric transform.
// pub type Iso5flt = Transform<Rot5flt, Vec5flt>;
/// 5-dimensional `f64`-valued general transform.
pub type Aff5f64 = Transform<Mat5f64, Vec5f64>; pub type Aff5f64 = Transform<Mat5f64, Vec5f64>;
/// 5-dimensional `f32`-valued general transform.
pub type Aff5f32 = Transform<Mat5f32, Vec5f32>; pub type Aff5f32 = Transform<Mat5f32, Vec5f32>;
/// 5-dimensional `float`-valued general transform.
pub type Aff5flt = Transform<Mat5flt, Vec5flt>; pub type Aff5flt = Transform<Mat5flt, Vec5flt>;
// 6D // 6D
/// 6-dimensional `f64`-valued vector.
pub type Vec6f64 = Vec6<f64>; pub type Vec6f64 = Vec6<f64>;
/// 6-dimensional `f32`-valued vector.
pub type Vec6f32 = Vec6<f32>; pub type Vec6f32 = Vec6<f32>;
/// 6-dimensional `float`-valued vector.
pub type Vec6flt = Vec6<float>; pub type Vec6flt = Vec6<float>;
/// 6-dimensional `f64`-valued matrix.
pub type Mat6f64 = Mat6<f64>; pub type Mat6f64 = Mat6<f64>;
/// 6-dimensional `f32`-valued matrix.
pub type Mat6f32 = Mat6<f32>; pub type Mat6f32 = Mat6<f32>;
/// 6-dimensional `float`-valued matrix.
pub type Mat6flt = Mat6<float>; pub type Mat6flt = Mat6<float>;
pub type Rot6f64 = Rotmat<Mat6<f64>>; // /// 6-dimensional `f64`-valued rotation matrix.
pub type Rot6f32 = Rotmat<Mat6<f32>>; // pub type Rot6f64 = Rotmat<Mat6<f64>>;
pub type Rot6flt = Rotmat<Mat6<float>>; // /// 6-dimensional `f32`-valued rotation matrix.
// pub type Rot6f32 = Rotmat<Mat6<f32>>;
pub type Iso6f64 = Transform<Rot6f64, Vec6f64>; // /// 6-dimensional `float`-valued rotation matrix.
pub type Iso6f32 = Transform<Rot6f32, Vec6f32>; // pub type Rot6flt = Rotmat<Mat6<float>>;
pub type Iso6flt = Transform<Rot6flt, Vec6flt>; //
// /// 6-dimensional `f64`-valued isometric transform.
// pub type Iso6f64 = Transform<Rot6f64, Vec6f64>;
// /// 6-dimensional `f32`-valued isometric transform.
// pub type Iso6f32 = Transform<Rot6f32, Vec6f32>;
// /// 6-dimensional `float`-valued isometric transform.
// pub type Iso6flt = Transform<Rot6flt, Vec6flt>;
/// 6-dimensional `f64`-valued general transform.
pub type Aff6f64 = Transform<Mat6f64, Vec6f64>; pub type Aff6f64 = Transform<Mat6f64, Vec6f64>;
/// 6-dimensional `f32`-valued general transform.
pub type Aff6f32 = Transform<Mat6f32, Vec6f32>; pub type Aff6f32 = Transform<Mat6f32, Vec6f32>;
/// 6-dimensional `float`-valued general transform.
pub type Aff6flt = Transform<Mat6flt, Vec6flt>; pub type Aff6flt = Transform<Mat6flt, Vec6flt>;

View File

@ -161,7 +161,7 @@ macro_rules! basis_impl(
elt = elt - self.scalar_mul(&basis_element.dot(self)); elt = elt - self.scalar_mul(&basis_element.dot(self));
for basis.iter().advance |v| foreach v in basis.iter()
{ elt = elt - v.scalar_mul(&elt.dot(v)) }; { elt = elt - v.scalar_mul(&elt.dot(v)) };
if !elt.sqnorm().approx_eq(&Zero::zero()) if !elt.sqnorm().approx_eq(&Zero::zero())