Remove useless or incomplete structs: Vec0, Pnt0, Iso4, Rot4.

This commit is contained in:
Sébastien Crozet 2016-03-24 19:03:44 +01:00
parent 0c8b8bfcdb
commit 88fb33cf44
9 changed files with 31 additions and 490 deletions

View File

@ -44,17 +44,17 @@ fn main() {
**nalgebra** is meant to be a general-purpose, low-dimensional, linear algebra library, with **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: 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`. * 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 `. * Square matrices with static sizes: `Mat1`, `Mat2`, `Mat3`, `Mat4`, `Mat5`, `Mat6 `.
* Rotation matrices: `Rot2`, `Rot3`, `Rot4`. * Rotation matrices: `Rot2`, `Rot3`
* Quaternions: `Quat`, `UnitQuat`. * Quaternions: `Quat`, `UnitQuat`.
* Isometries (translation * rotation): `Iso2`, `Iso3`, `Iso4`. * Isometries (translation * rotation): `Iso2`, `Iso3`
* Similarities (translation * rotation * uniform scale): `Sim2`, `Sim3`. * Similarity transformations (translation * rotation * uniform scale): `Sim2`, `Sim3`.
* 3D projections for computer graphics: `Persp3`, `PerspMat3`, `Ortho3`, `OrthoMat3`. * 3D projections for computer graphics: `Persp3`, `PerspMat3`, `Ortho3`, `OrthoMat3`.
* Dynamically sized heap-allocated vector: `DVec`. * Dynamically sized heap-allocated vector: `DVec`.
* Dynamically sized stack-allocated vectors with a maximum size: `DVec1` to `DVec6`. * Dynamically sized stack-allocated vectors with a maximum size: `DVec1` to `DVec6`.
* Dynamically sized heap-allocated (square or rectangular) matrix: `DMat`. * 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. * Almost one trait per functionality: useful for generic programming.

View File

@ -41,19 +41,19 @@ fn main() {
**nalgebra** is meant to be a general-purpose, low-dimensional, linear algebra library, with **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: 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`. * 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 `. * Square matrices with static sizes: `Mat1`, `Mat2`, `Mat3`, `Mat4`, `Mat5`, `Mat6 `.
* Rotation matrices: `Rot2`, `Rot3`, `Rot4`. * Rotation matrices: `Rot2`, `Rot3`
* Quaternions: `Quat`, `UnitQuat`. * Quaternions: `Quat`, `UnitQuat`.
* Isometries (translation * rotation): `Iso2`, `Iso3`, `Iso4`. * Isometries (translation * rotation): `Iso2`, `Iso3`
* Similarity transformations (translation * rotation * uniform scale): `Sim2`, `Sim3`. * Similarity transformations (translation * rotation * uniform scale): `Sim2`, `Sim3`.
* 3D projections for computer graphics: `Persp3`, `PerspMat3`, `Ortho3`, `OrthoMat3`. * 3D projections for computer graphics: `Persp3`, `PerspMat3`, `Ortho3`, `OrthoMat3`.
* Dynamically sized heap-allocated vector: `DVec`. * Dynamically sized heap-allocated vector: `DVec`.
* Dynamically sized stack-allocated vectors with a maximum size: `DVec1` to `DVec6`. * Dynamically sized stack-allocated vectors with a maximum size: `DVec1` to `DVec6`.
* Dynamically sized heap-allocated (square or rectangular) matrix: `DMat`. * 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. * Almost one trait per functionality: useful for generic programming.
@ -140,13 +140,13 @@ pub use structs::{
Identity, Identity,
DMat, DMat1, DMat2, DMat3, DMat4, DMat5, DMat6, DMat, DMat1, DMat2, DMat3, DMat4, DMat5, DMat6,
DVec, DVec1, DVec2, DVec3, DVec4, DVec5, DVec6, DVec, DVec1, DVec2, DVec3, DVec4, DVec5, DVec6,
Iso2, Iso3, Iso4, Iso2, Iso3,
Sim2, Sim3, Sim2, Sim3,
Mat1, Mat2, Mat3, Mat4, Mat1, Mat2, Mat3, Mat4,
Mat5, Mat6, Mat5, Mat6,
Rot2, Rot3, Rot4, Rot2, Rot3,
VecN, Vec0, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6, VecN, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6,
Pnt0, Pnt1, Pnt2, Pnt3, Pnt4, Pnt5, Pnt6, Pnt1, Pnt2, Pnt3, Pnt4, Pnt5, Pnt6,
Persp3, PerspMat3, Persp3, PerspMat3,
Ortho3, OrthoMat3, Ortho3, OrthoMat3,
Quat, UnitQuat Quat, UnitQuat

View File

@ -2,15 +2,14 @@ use std::ops::{Add, Sub, Mul, Neg};
use rand::{Rand, Rng}; use rand::{Rand, Rng};
use num::One; use num::One;
use structs::mat::{Mat3, Mat4, Mat5}; use structs::mat::{Mat3, Mat4};
use traits::structure::{Cast, Dim, Col, BaseFloat, BaseNum}; use traits::structure::{Cast, Dim, Col, BaseFloat, BaseNum};
use traits::operations::{Inv, ApproxEq}; use traits::operations::{Inv, ApproxEq};
use traits::geometry::{RotationMatrix, Rotation, Rotate, AbsoluteRotate, Transform, Transformation, use traits::geometry::{RotationMatrix, Rotation, Rotate, AbsoluteRotate, Transform, Transformation,
Translate, Translation, ToHomogeneous}; Translate, Translation, ToHomogeneous};
use structs::vec::{Vec1, Vec2, Vec3};
use structs::vec::{Vec1, Vec2, Vec3, Vec4}; use structs::pnt::{Pnt2, Pnt3};
use structs::pnt::{Pnt2, Pnt3, Pnt4}; use structs::rot::{Rot2, Rot3};
use structs::rot::{Rot2, Rot3, Rot4};
#[cfg(feature="arbitrary")] #[cfg(feature="arbitrary")]
use quickcheck::{Arbitrary, Gen}; use quickcheck::{Arbitrary, Gen};
@ -44,20 +43,6 @@ pub struct Iso3<N> {
pub translation: Vec3<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> { impl<N: Clone + BaseFloat> Iso3<N> {
/// Reorient and translate this transformation such that its local `x` axis points to a given /// 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 /// direction. Note that the usually known `look_at` function does the same thing but with the
@ -69,6 +54,7 @@ impl<N: Clone + BaseFloat> Iso3<N> {
/// aligned with. /// aligned with.
/// * up - Vector pointing up. The only requirement of this parameter is to not be colinear /// * up - Vector pointing up. The only requirement of this parameter is to not be colinear
/// with `at`. Non-colinearity is not checked. /// with `at`. Non-colinearity is not checked.
#[inline]
pub fn look_at(eye: &Pnt3<N>, at: &Pnt3<N>, up: &Vec3<N>) -> Iso3<N> { 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)) Iso3::new_with_rotmat(eye.as_vec().clone(), Rot3::look_at(&(*at - *eye), up))
} }
@ -82,23 +68,12 @@ impl<N: Clone + BaseFloat> Iso3<N> {
/// aligned with /// aligned with
/// * up - Vector pointing `up`. The only requirement of this parameter is to not be colinear /// * up - Vector pointing `up`. The only requirement of this parameter is to not be colinear
/// with `at`. Non-colinearity is not checked. /// with `at`. Non-colinearity is not checked.
#[inline]
pub fn look_at_z(eye: &Pnt3<N>, at: &Pnt3<N>, up: &Vec3<N>) -> Iso3<N> { 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)) 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); iso_impl!(Iso2, Rot2, Vec2, Vec1);
rotation_matrix_impl!(Iso2, Rot2, Vec2, Vec1); rotation_matrix_impl!(Iso2, Rot2, Vec2, Vec1);
rotation_impl!(Iso2, Rot2, Vec1); rotation_impl!(Iso2, Rot2, Vec1);
@ -142,26 +117,3 @@ pnt_mul_iso_impl!(Iso3, Pnt3);
iso_mul_vec_impl!(Iso3, Vec3); iso_mul_vec_impl!(Iso3, Vec3);
vec_mul_iso_impl!(Iso3, Vec3); vec_mul_iso_impl!(Iso3, Vec3);
arbitrary_iso_impl!(Iso3); 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);

View File

@ -2,12 +2,12 @@
pub use self::dmat::{DMat, DMat1, DMat2, DMat3, DMat4, DMat5, DMat6}; 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::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::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::mat::{Identity, Mat1, Mat2, Mat3, Mat4, Mat5, Mat6};
pub use self::rot::{Rot2, Rot3, Rot4}; pub use self::rot::{Rot2, Rot3};
pub use self::iso::{Iso2, Iso3, Iso4}; pub use self::iso::{Iso2, Iso3};
pub use self::sim::{Sim2, Sim3}; pub use self::sim::{Sim2, Sim3};
pub use self::persp::{Persp3, PerspMat3}; pub use self::persp::{Persp3, PerspMat3};
pub use self::ortho::{Ortho3, OrthoMat3}; pub use self::ortho::{Ortho3, OrthoMat3};
@ -40,7 +40,6 @@ mod ortho;
mod spec { mod spec {
mod identity; mod identity;
mod mat; mod mat;
mod vec0;
mod vec; mod vec;
mod primitives; mod primitives;
// mod complex; // mod complex;

View File

@ -2,7 +2,6 @@
#![allow(missing_docs)] // we allow missing to avoid having to document the point components. #![allow(missing_docs)] // we allow missing to avoid having to document the point components.
use std::marker::PhantomData;
use std::mem; use std::mem;
use std::slice::{Iter, IterMut}; use std::slice::{Iter, IterMut};
use std::iter::{Iterator, FromIterator, IntoIterator}; use std::iter::{Iterator, FromIterator, IntoIterator};
@ -18,29 +17,6 @@ use structs::vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
use quickcheck::{Arbitrary, Gen}; 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. /// Point of dimension 1.
/// ///
/// The main differance between a point and a vector is that a vector is not affected by /// The main differance between a point and a vector is that a vector is not affected by

View File

@ -9,9 +9,9 @@ use traits::geometry::{Rotate, Rotation, AbsoluteRotate, RotationMatrix, Rotatio
ToHomogeneous, Norm, Cross}; ToHomogeneous, Norm, Cross};
use traits::structure::{Cast, Dim, Row, Col, BaseFloat, BaseNum, Eye, Diag}; use traits::structure::{Cast, Dim, Row, Col, BaseFloat, BaseNum, Eye, Diag};
use traits::operations::{Absolute, Inv, Transpose, ApproxEq}; use traits::operations::{Absolute, Inv, Transpose, ApproxEq};
use structs::vec::{Vec1, Vec2, Vec3, Vec4}; use structs::vec::{Vec1, Vec2, Vec3};
use structs::pnt::{Pnt2, Pnt3, Pnt4}; use structs::pnt::{Pnt2, Pnt3};
use structs::mat::{Mat2, Mat3, Mat4, Mat5}; use structs::mat::{Mat2, Mat3, Mat4};
#[cfg(feature="arbitrary")] #[cfg(feature="arbitrary")]
use quickcheck::{Arbitrary, Gen}; use quickcheck::{Arbitrary, Gen};
@ -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. * Common implementations.
*/ */
@ -478,25 +392,3 @@ inv_impl!(Rot3);
transpose_impl!(Rot3); transpose_impl!(Rot3);
approx_eq_impl!(Rot3); approx_eq_impl!(Rot3);
diag_impl!(Rot3, Vec3); 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);

View File

@ -12,6 +12,9 @@ use structs::pnt::{Pnt2, Pnt3};
use structs::rot::{Rot2, Rot3}; use structs::rot::{Rot2, Rot3};
use structs::iso::{Iso2, Iso3}; 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… // FIXME: the name is not explicit at all but coherent with the other tree-letters names…
/// A two-dimensional similarity transformation. /// A two-dimensional similarity transformation.
/// ///

View File

@ -1,257 +0,0 @@
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut};
use std::marker::PhantomData;
use std::mem;
use std::slice::{Iter, IterMut};
use std::iter::{FromIterator, IntoIterator};
use rand::{Rand, Rng};
use num::{Zero, One};
use traits::operations::ApproxEq;
use traits::structure::{Iterable, IterableMut, Indexable, Basis, Dim, Shape, BaseFloat, BaseNum, Bounded};
use traits::geometry::{Translation, Dot, Norm};
use structs::vec;
impl<N> Zero for vec::Vec0<N> {
#[inline]
fn zero() -> vec::Vec0<N> {
vec::Vec0(PhantomData)
}
#[inline]
fn is_zero(&self) -> bool {
true
}
}
impl<N> Index<usize> for vec::Vec0<N> {
type Output = N;
#[inline]
fn index(&self, _: usize) -> &N {
panic!("Canot index a Vec0.")
}
}
impl<N> IndexMut<usize> for vec::Vec0<N> {
#[inline]
fn index_mut(&mut self, _: usize) -> &mut N {
panic!("Canot index a Vec0.")
}
}
impl<N> Shape<usize> for vec::Vec0<N> {
#[inline]
fn shape(&self) -> usize {
0
}
}
impl<N> Indexable<usize, N> for vec::Vec0<N> {
#[inline]
fn swap(&mut self, _: usize, _: usize) {
}
#[inline]
unsafe fn unsafe_at(&self, _: usize) -> N {
panic!("Cannot index a Vec0.")
}
#[inline]
unsafe fn unsafe_set(&mut self, _: usize, _: N) {
}
}
impl<N: 'static> Iterable<N> for vec::Vec0<N> {
#[inline]
fn iter<'l>(&'l self) -> Iter<'l, N> {
unsafe { mem::transmute::<&'l vec::Vec0<N>, &'l [N; 0]>(self).iter() }
}
}
impl<N: 'static> IterableMut<N> for vec::Vec0<N> {
#[inline]
fn iter_mut<'l>(&'l mut self) -> IterMut<'l, N> {
unsafe { mem::transmute::<&'l mut vec::Vec0<N>, &'l mut [N; 0]>(self).iter_mut() }
}
}
impl<N> Dim for vec::Vec0<N> {
#[inline]
fn dim(_: Option<vec::Vec0<N>>) -> usize {
0
}
}
impl<N> Basis for vec::Vec0<N> {
#[inline(always)]
fn canonical_basis<F: FnMut(vec::Vec0<N>) -> bool>(_: F) { }
#[inline(always)]
fn orthonormal_subspace_basis<F: FnMut(vec::Vec0<N>) -> bool>(_: &vec::Vec0<N>, _: F) { }
#[inline(always)]
fn canonical_basis_element(_: usize) -> Option<vec::Vec0<N>> {
None
}
}
impl<N, T> Add<T> for vec::Vec0<N> {
type Output = vec::Vec0<N>;
#[inline]
fn add(self, _: T) -> vec::Vec0<N> {
vec::Vec0(PhantomData)
}
}
impl<N, T> Sub<T> for vec::Vec0<N> {
type Output = vec::Vec0<N>;
#[inline]
fn sub(self, _: T) -> vec::Vec0<N> {
vec::Vec0(PhantomData)
}
}
impl<N: Neg<Output = N> + Copy> Neg for vec::Vec0<N> {
type Output = vec::Vec0<N>;
#[inline]
fn neg(self) -> vec::Vec0<N> {
vec::Vec0(PhantomData)
}
}
impl<N: BaseNum> Dot<N> for vec::Vec0<N> {
#[inline]
fn dot(&self, _: &vec::Vec0<N>) -> N {
::zero()
}
}
impl<N, T> Mul<T> for vec::Vec0<N> {
type Output = vec::Vec0<N>;
#[inline]
fn mul(self, _: T) -> vec::Vec0<N> {
vec::Vec0(PhantomData)
}
}
impl<N, T> Div<T> for vec::Vec0<N> {
type Output = vec::Vec0<N>;
#[inline]
fn div(self, _: T) -> vec::Vec0<N> {
vec::Vec0(PhantomData)
}
}
impl<N: Copy + Add<N, Output = N> + Neg<Output = N>> Translation<vec::Vec0<N>> for vec::Vec0<N> {
#[inline]
fn translation(&self) -> vec::Vec0<N> {
*self
}
#[inline]
fn inv_translation(&self) -> vec::Vec0<N> {
-*self
}
#[inline]
fn append_translation_mut(&mut self, t: &vec::Vec0<N>) {
*self = *t + *self;
}
#[inline]
fn append_translation(&self, t: &vec::Vec0<N>) -> vec::Vec0<N> {
*t + self
}
#[inline]
fn prepend_translation_mut(&mut self, t: &vec::Vec0<N>) {
*self = *self + *t;
}
#[inline]
fn prepend_translation(&self, t: &vec::Vec0<N>) -> vec::Vec0<N> {
*self + *t
}
#[inline]
fn set_translation(&mut self, _: vec::Vec0<N>) {
}
}
impl<N: BaseFloat> Norm<N> for vec::Vec0<N> {
#[inline]
fn sqnorm(&self) -> N {
::zero()
}
#[inline]
fn norm(&self) -> N {
::zero()
}
#[inline]
fn normalize(&self) -> vec::Vec0<N> {
::zero()
}
#[inline]
fn normalize_mut(&mut self) -> N {
::zero()
}
}
impl<N: ApproxEq<N>> ApproxEq<N> for vec::Vec0<N> {
#[inline]
fn approx_epsilon(_: Option<vec::Vec0<N>>) -> N {
ApproxEq::approx_epsilon(None::<N>)
}
fn approx_ulps(_: Option<vec::Vec0<N>>) -> u32 {
ApproxEq::approx_ulps(None::<N>)
}
#[inline]
fn approx_eq_eps(&self, _: &vec::Vec0<N>, _: &N) -> bool {
true
}
#[inline]
fn approx_eq_ulps(&self, _: &vec::Vec0<N>, _: u32) -> bool {
true
}
}
impl<N: One> One for vec::Vec0<N> {
#[inline]
fn one() -> vec::Vec0<N> {
vec::Vec0(PhantomData)
}
}
impl<N> FromIterator<N> for vec::Vec0<N> {
#[inline]
fn from_iter<I: IntoIterator<Item = N>>(_: I) -> vec::Vec0<N> {
vec::Vec0(PhantomData)
}
}
impl<N: Bounded> Bounded for vec::Vec0<N> {
#[inline]
fn max_value() -> vec::Vec0<N> {
vec::Vec0(PhantomData)
}
#[inline]
fn min_value() -> vec::Vec0<N> {
vec::Vec0(PhantomData)
}
}
impl<N> Rand for vec::Vec0<N> {
#[inline]
fn rand<R: Rng>(_: &mut R) -> vec::Vec0<N> { vec::Vec0(PhantomData) }
}

View File

@ -3,7 +3,6 @@
#![allow(missing_docs)] // we allow missing to avoid having to document the dispatch traits. #![allow(missing_docs)] // we allow missing to avoid having to document the dispatch traits.
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut}; use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut};
use std::marker::PhantomData;
use std::mem; use std::mem;
use std::slice::{Iter, IterMut}; use std::slice::{Iter, IterMut};
use std::iter::{Iterator, FromIterator, IntoIterator}; use std::iter::{Iterator, FromIterator, IntoIterator};
@ -20,29 +19,6 @@ use structs::pnt::{Pnt1, Pnt2, Pnt3, Pnt4, Pnt5, Pnt6};
use quickcheck::{Arbitrary, Gen}; use quickcheck::{Arbitrary, Gen};
/// Vector 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 Vec0<N>(pub PhantomData<N>);
impl<N> Vec0<N> {
/// Creates a new vector.
#[inline]
pub fn new() -> Vec0<N> {
Vec0(PhantomData)
}
}
impl<N> Repeat<N> for Vec0<N> {
#[inline]
fn repeat(_: N) -> Vec0<N> {
Vec0(PhantomData)
}
}
/// Vector of dimension 1. /// Vector of dimension 1.
/// ///
/// The main differance between a point and a vector is that a vector is not affected by /// The main differance between a point and a vector is that a vector is not affected by