Skip to content

Commit

Permalink
Remove useless or incomplete structs: Vec0, Pnt0, Iso4, Rot4.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebcrozet committed Mar 24, 2016
1 parent 0c8b8bf commit 88fb33c
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 490 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ fn main() {
**nalgebra** is meant to be a general-purpose, low-dimensional, linear algebra library, with
an optimized set of tools for computer graphics and physics. Those features include:

* Vectors with predefined static sizes: `Vec0`, `Vec1`, `Vec2`, `Vec3`, `Vec4`, `Vec5`, `Vec6`.
* Vectors with predefined static sizes: `Vec1`, `Vec2`, `Vec3`, `Vec4`, `Vec5`, `Vec6`.
* Vector with a user-defined static size: `VecN`.
* Points with static sizes: `Pnt0`, `Pnt1`, `Pnt2`, `Pnt3`, `Pnt4`, `Pnt5`, `Pnt6`.
* Points with static sizes: ``Pnt1`, `Pnt2`, `Pnt3`, `Pnt4`, `Pnt5`, `Pnt6`.
* Square matrices with static sizes: `Mat1`, `Mat2`, `Mat3`, `Mat4`, `Mat5`, `Mat6 `.
* Rotation matrices: `Rot2`, `Rot3`, `Rot4`.
* Rotation matrices: `Rot2`, `Rot3`
* Quaternions: `Quat`, `UnitQuat`.
* Isometries (translation * rotation): `Iso2`, `Iso3`, `Iso4`.
* Similarities (translation * rotation * uniform scale): `Sim2`, `Sim3`.
* Isometries (translation * rotation): `Iso2`, `Iso3`
* Similarity transformations (translation * rotation * uniform scale): `Sim2`, `Sim3`.
* 3D projections for computer graphics: `Persp3`, `PerspMat3`, `Ortho3`, `OrthoMat3`.
* Dynamically sized heap-allocated vector: `DVec`.
* Dynamically sized stack-allocated vectors with a maximum size: `DVec1` to `DVec6`.
* Dynamically sized heap-allocated (square or rectangular) matrix: `DMat`.
* A few methods for data analysis: `Cov`, `Mean`.
* Linear algebra and data analysis operators: `Cov`, `Mean`, `qr`, `cholesky`.
* Almost one trait per functionality: useful for generic programming.
18 changes: 9 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ fn main() {
**nalgebra** is meant to be a general-purpose, low-dimensional, linear algebra library, with
an optimized set of tools for computer graphics and physics. Those features include:
* Vectors with predefined static sizes: `Vec0`, `Vec1`, `Vec2`, `Vec3`, `Vec4`, `Vec5`, `Vec6`.
* Vectors with predefined static sizes: `Vec1`, `Vec2`, `Vec3`, `Vec4`, `Vec5`, `Vec6`.
* Vector with a user-defined static size: `VecN`.
* Points with static sizes: `Pnt0`, `Pnt1`, `Pnt2`, `Pnt3`, `Pnt4`, `Pnt5`, `Pnt6`.
* Points with static sizes: `Pnt1`, `Pnt2`, `Pnt3`, `Pnt4`, `Pnt5`, `Pnt6`.
* Square matrices with static sizes: `Mat1`, `Mat2`, `Mat3`, `Mat4`, `Mat5`, `Mat6 `.
* Rotation matrices: `Rot2`, `Rot3`, `Rot4`.
* Rotation matrices: `Rot2`, `Rot3`
* Quaternions: `Quat`, `UnitQuat`.
* Isometries (translation * rotation): `Iso2`, `Iso3`, `Iso4`.
* Isometries (translation * rotation): `Iso2`, `Iso3`
* Similarity transformations (translation * rotation * uniform scale): `Sim2`, `Sim3`.
* 3D projections for computer graphics: `Persp3`, `PerspMat3`, `Ortho3`, `OrthoMat3`.
* Dynamically sized heap-allocated vector: `DVec`.
* Dynamically sized stack-allocated vectors with a maximum size: `DVec1` to `DVec6`.
* Dynamically sized heap-allocated (square or rectangular) matrix: `DMat`.
* A few methods for data analysis: `Cov`, `Mean`.
* Linear algebra and data analysis operators: `Cov`, `Mean`, `qr`, `cholesky`.
* Almost one trait per functionality: useful for generic programming.
Expand Down Expand Up @@ -140,13 +140,13 @@ pub use structs::{
Identity,
DMat, DMat1, DMat2, DMat3, DMat4, DMat5, DMat6,
DVec, DVec1, DVec2, DVec3, DVec4, DVec5, DVec6,
Iso2, Iso3, Iso4,
Iso2, Iso3,
Sim2, Sim3,
Mat1, Mat2, Mat3, Mat4,
Mat5, Mat6,
Rot2, Rot3, Rot4,
VecN, Vec0, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6,
Pnt0, Pnt1, Pnt2, Pnt3, Pnt4, Pnt5, Pnt6,
Rot2, Rot3,
VecN, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6,
Pnt1, Pnt2, Pnt3, Pnt4, Pnt5, Pnt6,
Persp3, PerspMat3,
Ortho3, OrthoMat3,
Quat, UnitQuat
Expand Down
60 changes: 6 additions & 54 deletions src/structs/iso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ use std::ops::{Add, Sub, Mul, Neg};

use rand::{Rand, Rng};
use num::One;
use structs::mat::{Mat3, Mat4, Mat5};
use structs::mat::{Mat3, Mat4};
use traits::structure::{Cast, Dim, Col, BaseFloat, BaseNum};
use traits::operations::{Inv, ApproxEq};
use traits::geometry::{RotationMatrix, Rotation, Rotate, AbsoluteRotate, Transform, Transformation,
Translate, Translation, ToHomogeneous};

use structs::vec::{Vec1, Vec2, Vec3, Vec4};
use structs::pnt::{Pnt2, Pnt3, Pnt4};
use structs::rot::{Rot2, Rot3, Rot4};
use structs::vec::{Vec1, Vec2, Vec3};
use structs::pnt::{Pnt2, Pnt3};
use structs::rot::{Rot2, Rot3};

#[cfg(feature="arbitrary")]
use quickcheck::{Arbitrary, Gen};
Expand Down Expand Up @@ -44,20 +43,6 @@ pub struct Iso3<N> {
pub translation: Vec3<N>
}

/// Four dimensional isometry.
///
/// This is the composition of a rotation followed by a translation. Vectors `Vec4` are not
/// affected by the translational component of this transformation while points `Pnt4` are.
/// Isometries conserve angles and distances, hence do not allow shearing nor scaling.
#[repr(C)]
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Copy)]
pub struct Iso4<N> {
/// The rotation applicable by this isometry.
pub rotation: Rot4<N>,
/// The translation applicable by this isometry.
pub translation: Vec4<N>
}

impl<N: Clone + BaseFloat> Iso3<N> {
/// Reorient and translate this transformation such that its local `x` axis points to a given
/// direction. Note that the usually known `look_at` function does the same thing but with the
Expand All @@ -69,6 +54,7 @@ impl<N: Clone + BaseFloat> Iso3<N> {
/// aligned with.
/// * up - Vector pointing up. The only requirement of this parameter is to not be colinear
/// with `at`. Non-colinearity is not checked.
#[inline]
pub fn look_at(eye: &Pnt3<N>, at: &Pnt3<N>, up: &Vec3<N>) -> Iso3<N> {
Iso3::new_with_rotmat(eye.as_vec().clone(), Rot3::look_at(&(*at - *eye), up))
}
Expand All @@ -82,23 +68,12 @@ impl<N: Clone + BaseFloat> Iso3<N> {
/// aligned with
/// * up - Vector pointing `up`. The only requirement of this parameter is to not be colinear
/// with `at`. Non-colinearity is not checked.
#[inline]
pub fn look_at_z(eye: &Pnt3<N>, at: &Pnt3<N>, up: &Vec3<N>) -> Iso3<N> {
Iso3::new_with_rotmat(eye.as_vec().clone(), Rot3::look_at_z(&(*at - *eye), up))
}
}

impl<N> Iso4<N> {
// XXX remove that when iso_impl works for Iso4
/// Creates a new isometry from a rotation matrix and a vector.
#[inline]
pub fn new_with_rotmat(translation: Vec4<N>, rotation: Rot4<N>) -> Iso4<N> {
Iso4 {
rotation: rotation,
translation: translation
}
}
}

iso_impl!(Iso2, Rot2, Vec2, Vec1);
rotation_matrix_impl!(Iso2, Rot2, Vec2, Vec1);
rotation_impl!(Iso2, Rot2, Vec1);
Expand Down Expand Up @@ -142,26 +117,3 @@ pnt_mul_iso_impl!(Iso3, Pnt3);
iso_mul_vec_impl!(Iso3, Vec3);
vec_mul_iso_impl!(Iso3, Vec3);
arbitrary_iso_impl!(Iso3);

// iso_impl!(Iso4, Rot4, Vec4, Vec4);
// rotation_matrix_impl!(Iso4, Rot4, Vec4, Vec4);
// rotation_impl!(Iso4, Rot4, Vec4);
dim_impl!(Iso4, 4);
one_impl!(Iso4);
absolute_rotate_impl!(Iso4, Vec4);
// rand_impl!(Iso4);
approx_eq_impl!(Iso4);
to_homogeneous_impl!(Iso4, Mat5);
inv_impl!(Iso4);
transform_impl!(Iso4, Pnt4);
transformation_impl!(Iso4);
rotate_impl!(Iso4, Vec4);
translation_impl!(Iso4, Vec4);
translate_impl!(Iso4, Pnt4);
iso_mul_iso_impl!(Iso4);
iso_mul_pnt_impl!(Iso4, Pnt4);
pnt_mul_iso_impl!(Iso4, Pnt4);
iso_mul_vec_impl!(Iso4, Vec4);
vec_mul_iso_impl!(Iso4, Vec4);
// FIXME: as soon as Rot4<N>: Arbitrary
// arbitrary_iso_impl!(Iso4);
9 changes: 4 additions & 5 deletions src/structs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
pub use self::dmat::{DMat, DMat1, DMat2, DMat3, DMat4, DMat5, DMat6};
pub use self::dvec::{DVec, DVec1, DVec2, DVec3, DVec4, DVec5, DVec6};
pub use self::vec::{Vec0, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
pub use self::vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
pub use self::vecn::VecN;
pub use self::pnt::{Pnt0, Pnt1, Pnt2, Pnt3, Pnt4, Pnt5, Pnt6};
pub use self::pnt::{Pnt1, Pnt2, Pnt3, Pnt4, Pnt5, Pnt6};
pub use self::mat::{Identity, Mat1, Mat2, Mat3, Mat4, Mat5, Mat6};
pub use self::rot::{Rot2, Rot3, Rot4};
pub use self::iso::{Iso2, Iso3, Iso4};
pub use self::rot::{Rot2, Rot3};
pub use self::iso::{Iso2, Iso3};
pub use self::sim::{Sim2, Sim3};
pub use self::persp::{Persp3, PerspMat3};
pub use self::ortho::{Ortho3, OrthoMat3};
Expand Down Expand Up @@ -40,7 +40,6 @@ mod ortho;
mod spec {
mod identity;
mod mat;
mod vec0;
mod vec;
mod primitives;
// mod complex;
Expand Down
24 changes: 0 additions & 24 deletions src/structs/pnt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![allow(missing_docs)] // we allow missing to avoid having to document the point components.

use std::marker::PhantomData;
use std::mem;
use std::slice::{Iter, IterMut};
use std::iter::{Iterator, FromIterator, IntoIterator};
Expand All @@ -18,29 +17,6 @@ use structs::vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
use quickcheck::{Arbitrary, Gen};


/// Point of dimension 0.
///
/// The main differance between a point and a vector is that a vector is not affected by
/// translations.
#[repr(C)]
#[derive(Eq, PartialEq, Clone, Debug, Copy)]
pub struct Pnt0<N>(pub PhantomData<N>);

impl<N> Pnt0<N> {
/// Creates a new point.
#[inline]
pub fn new() -> Pnt0<N> {
Pnt0(PhantomData)
}
}

impl<N> Repeat<N> for Pnt0<N> {
#[inline]
fn repeat(_: N) -> Pnt0<N> {
Pnt0(PhantomData)
}
}

/// Point of dimension 1.
///
/// The main differance between a point and a vector is that a vector is not affected by
Expand Down
114 changes: 3 additions & 111 deletions src/structs/rot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use traits::geometry::{Rotate, Rotation, AbsoluteRotate, RotationMatrix, Rotatio
ToHomogeneous, Norm, Cross};
use traits::structure::{Cast, Dim, Row, Col, BaseFloat, BaseNum, Eye, Diag};
use traits::operations::{Absolute, Inv, Transpose, ApproxEq};
use structs::vec::{Vec1, Vec2, Vec3, Vec4};
use structs::pnt::{Pnt2, Pnt3, Pnt4};
use structs::mat::{Mat2, Mat3, Mat4, Mat5};
use structs::vec::{Vec1, Vec2, Vec3};
use structs::pnt::{Pnt2, Pnt3};
use structs::mat::{Mat2, Mat3, Mat4};
#[cfg(feature="arbitrary")]
use quickcheck::{Arbitrary, Gen};

Expand Down Expand Up @@ -345,92 +345,6 @@ impl<N: Arbitrary + Clone + BaseFloat> Arbitrary for Rot3<N> {
}


/// Four dimensional rotation matrix.
#[repr(C)]
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Hash, Copy)]
pub struct Rot4<N> {
submat: Mat4<N>
}

// impl<N> Rot4<N> {
// pub fn new(left_iso: Quat<N>, right_iso: Quat<N>) -> Rot4<N> {
// assert!(left_iso.is_unit());
// assert!(right_iso.is_unright);
//
// let mat_left_iso = Mat4::new(
// left_iso.x, -left_iso.y, -left_iso.z, -left_iso.w,
// left_iso.y, left_iso.x, -left_iso.w, left_iso.z,
// left_iso.z, left_iso.w, left_iso.x, -left_iso.y,
// left_iso.w, -left_iso.z, left_iso.y, left_iso.x);
// let mat_right_iso = Mat4::new(
// right_iso.x, -right_iso.y, -right_iso.z, -right_iso.w,
// right_iso.y, right_iso.x, right_iso.w, -right_iso.z,
// right_iso.z, -right_iso.w, right_iso.x, right_iso.y,
// right_iso.w, right_iso.z, -right_iso.y, right_iso.x);
//
// Rot4 {
// submat: mat_left_iso * mat_right_iso
// }
// }
// }

impl<N: BaseFloat> AbsoluteRotate<Vec4<N>> for Rot4<N> {
#[inline]
fn absolute_rotate(&self, v: &Vec4<N>) -> Vec4<N> {
Vec4::new(
::abs(&self.submat.m11) * v.x + ::abs(&self.submat.m12) * v.y +
::abs(&self.submat.m13) * v.z + ::abs(&self.submat.m14) * v.w,

::abs(&self.submat.m21) * v.x + ::abs(&self.submat.m22) * v.y +
::abs(&self.submat.m23) * v.z + ::abs(&self.submat.m24) * v.w,

::abs(&self.submat.m31) * v.x + ::abs(&self.submat.m32) * v.y +
::abs(&self.submat.m33) * v.z + ::abs(&self.submat.m34) * v.w,

::abs(&self.submat.m41) * v.x + ::abs(&self.submat.m42) * v.y +
::abs(&self.submat.m43) * v.z + ::abs(&self.submat.m44) * v.w)
}
}

impl<N: BaseFloat + Clone>
Rotation<Vec4<N>> for Rot4<N> {
#[inline]
fn rotation(&self) -> Vec4<N> {
panic!("Not yet implemented")
}

#[inline]
fn inv_rotation(&self) -> Vec4<N> {
panic!("Not yet implemented")
}

#[inline]
fn append_rotation_mut(&mut self, _: &Vec4<N>) {
panic!("Not yet implemented")
}

#[inline]
fn append_rotation(&self, _: &Vec4<N>) -> Rot4<N> {
panic!("Not yet implemented")
}

#[inline]
fn prepend_rotation_mut(&mut self, _: &Vec4<N>) {
panic!("Not yet implemented")
}

#[inline]
fn prepend_rotation(&self, _: &Vec4<N>) -> Rot4<N> {
panic!("Not yet implemented")
}

#[inline]
fn set_rotation(&mut self, _: Vec4<N>) {
panic!("Not yet implemented")
}
}


/*
* Common implementations.
*/
Expand Down Expand Up @@ -478,25 +392,3 @@ inv_impl!(Rot3);
transpose_impl!(Rot3);
approx_eq_impl!(Rot3);
diag_impl!(Rot3, Vec3);

submat_impl!(Rot4, Mat4);
rotate_impl!(Rot4, Vec4, Pnt4);
transform_impl!(Rot4, Vec4, Pnt4);
dim_impl!(Rot4, 4);
rot_mul_rot_impl!(Rot4);
rot_mul_vec_impl!(Rot4, Vec4);
vec_mul_rot_impl!(Rot4, Vec4);
rot_mul_pnt_impl!(Rot4, Pnt4);
pnt_mul_rot_impl!(Rot4, Pnt4);
one_impl!(Rot4);
eye_impl!(Rot4);
rotation_matrix_impl!(Rot4, Vec4, Vec4);
col_impl!(Rot4, Vec4);
row_impl!(Rot4, Vec4);
index_impl!(Rot4);
absolute_impl!(Rot4, Mat4);
to_homogeneous_impl!(Rot4, Mat5);
inv_impl!(Rot4);
transpose_impl!(Rot4);
approx_eq_impl!(Rot4);
diag_impl!(Rot4, Vec4);
3 changes: 3 additions & 0 deletions src/structs/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ use structs::pnt::{Pnt2, Pnt3};
use structs::rot::{Rot2, Rot3};
use structs::iso::{Iso2, Iso3};

#[cfg(feature="arbitrary")]
use quickcheck::{Arbitrary, Gen};

// FIXME: the name is not explicit at all but coherent with the other tree-letters names…
/// A two-dimensional similarity transformation.
///
Expand Down
Loading

0 comments on commit 88fb33c

Please sign in to comment.