From 88fb33cf4431b105d8da9df3bac2547afdfa6ed0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Thu, 24 Mar 2016 19:03:44 +0100 Subject: [PATCH] Remove useless or incomplete structs: `Vec0`, `Pnt0`, `Iso4`, `Rot4`. --- README.md | 12 +- src/lib.rs | 18 +-- src/structs/iso.rs | 60 +-------- src/structs/mod.rs | 9 +- src/structs/pnt.rs | 24 ---- src/structs/rot.rs | 114 +---------------- src/structs/sim.rs | 3 + src/structs/spec/vec0.rs | 257 --------------------------------------- src/structs/vec.rs | 24 ---- 9 files changed, 31 insertions(+), 490 deletions(-) delete mode 100644 src/structs/spec/vec0.rs diff --git a/README.md b/README.md index 68dc1126..718350af 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/lib.rs b/src/lib.rs index f5953f7e..706d8b40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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. @@ -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 diff --git a/src/structs/iso.rs b/src/structs/iso.rs index 7c022ed5..f3e84c2c 100644 --- a/src/structs/iso.rs +++ b/src/structs/iso.rs @@ -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}; @@ -44,20 +43,6 @@ pub struct Iso3 { pub translation: Vec3 } -/// 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 { - /// The rotation applicable by this isometry. - pub rotation: Rot4, - /// The translation applicable by this isometry. - pub translation: Vec4 -} - impl Iso3 { /// 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 @@ -69,6 +54,7 @@ impl Iso3 { /// 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, at: &Pnt3, up: &Vec3) -> Iso3 { Iso3::new_with_rotmat(eye.as_vec().clone(), Rot3::look_at(&(*at - *eye), up)) } @@ -82,23 +68,12 @@ impl Iso3 { /// 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, at: &Pnt3, up: &Vec3) -> Iso3 { Iso3::new_with_rotmat(eye.as_vec().clone(), Rot3::look_at_z(&(*at - *eye), up)) } } -impl Iso4 { - // 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, rotation: Rot4) -> Iso4 { - Iso4 { - rotation: rotation, - translation: translation - } - } -} - iso_impl!(Iso2, Rot2, Vec2, Vec1); rotation_matrix_impl!(Iso2, Rot2, Vec2, Vec1); rotation_impl!(Iso2, Rot2, Vec1); @@ -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: Arbitrary -// arbitrary_iso_impl!(Iso4); diff --git a/src/structs/mod.rs b/src/structs/mod.rs index c2888f56..c5354463 100644 --- a/src/structs/mod.rs +++ b/src/structs/mod.rs @@ -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}; @@ -40,7 +40,6 @@ mod ortho; mod spec { mod identity; mod mat; - mod vec0; mod vec; mod primitives; // mod complex; diff --git a/src/structs/pnt.rs b/src/structs/pnt.rs index f2d6fca0..b7524246 100644 --- a/src/structs/pnt.rs +++ b/src/structs/pnt.rs @@ -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}; @@ -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(pub PhantomData); - -impl Pnt0 { - /// Creates a new point. - #[inline] - pub fn new() -> Pnt0 { - Pnt0(PhantomData) - } -} - -impl Repeat for Pnt0 { - #[inline] - fn repeat(_: N) -> Pnt0 { - Pnt0(PhantomData) - } -} - /// Point of dimension 1. /// /// The main differance between a point and a vector is that a vector is not affected by diff --git a/src/structs/rot.rs b/src/structs/rot.rs index aa60f33d..b3a2791e 100644 --- a/src/structs/rot.rs +++ b/src/structs/rot.rs @@ -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}; @@ -345,92 +345,6 @@ impl Arbitrary for Rot3 { } -/// Four dimensional rotation matrix. -#[repr(C)] -#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Debug, Hash, Copy)] -pub struct Rot4 { - submat: Mat4 -} - -// impl Rot4 { -// pub fn new(left_iso: Quat, right_iso: Quat) -> Rot4 { -// 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 AbsoluteRotate> for Rot4 { - #[inline] - fn absolute_rotate(&self, v: &Vec4) -> Vec4 { - 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 -Rotation> for Rot4 { - #[inline] - fn rotation(&self) -> Vec4 { - panic!("Not yet implemented") - } - - #[inline] - fn inv_rotation(&self) -> Vec4 { - panic!("Not yet implemented") - } - - #[inline] - fn append_rotation_mut(&mut self, _: &Vec4) { - panic!("Not yet implemented") - } - - #[inline] - fn append_rotation(&self, _: &Vec4) -> Rot4 { - panic!("Not yet implemented") - } - - #[inline] - fn prepend_rotation_mut(&mut self, _: &Vec4) { - panic!("Not yet implemented") - } - - #[inline] - fn prepend_rotation(&self, _: &Vec4) -> Rot4 { - panic!("Not yet implemented") - } - - #[inline] - fn set_rotation(&mut self, _: Vec4) { - panic!("Not yet implemented") - } -} - - /* * Common implementations. */ @@ -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); diff --git a/src/structs/sim.rs b/src/structs/sim.rs index 299c385e..87af2ed1 100644 --- a/src/structs/sim.rs +++ b/src/structs/sim.rs @@ -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. /// diff --git a/src/structs/spec/vec0.rs b/src/structs/spec/vec0.rs deleted file mode 100644 index 84cf6b8b..00000000 --- a/src/structs/spec/vec0.rs +++ /dev/null @@ -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 Zero for vec::Vec0 { - #[inline] - fn zero() -> vec::Vec0 { - vec::Vec0(PhantomData) - } - - #[inline] - fn is_zero(&self) -> bool { - true - } -} - -impl Index for vec::Vec0 { - type Output = N; - - #[inline] - fn index(&self, _: usize) -> &N { - panic!("Canot index a Vec0.") - } -} - -impl IndexMut for vec::Vec0 { - #[inline] - fn index_mut(&mut self, _: usize) -> &mut N { - panic!("Canot index a Vec0.") - } -} - -impl Shape for vec::Vec0 { - #[inline] - fn shape(&self) -> usize { - 0 - } -} - -impl Indexable for vec::Vec0 { - #[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 Iterable for vec::Vec0 { - #[inline] - fn iter<'l>(&'l self) -> Iter<'l, N> { - unsafe { mem::transmute::<&'l vec::Vec0, &'l [N; 0]>(self).iter() } - } -} - -impl IterableMut for vec::Vec0 { - #[inline] - fn iter_mut<'l>(&'l mut self) -> IterMut<'l, N> { - unsafe { mem::transmute::<&'l mut vec::Vec0, &'l mut [N; 0]>(self).iter_mut() } - } -} - -impl Dim for vec::Vec0 { - #[inline] - fn dim(_: Option>) -> usize { - 0 - } -} - -impl Basis for vec::Vec0 { - #[inline(always)] - fn canonical_basis) -> bool>(_: F) { } - - #[inline(always)] - fn orthonormal_subspace_basis) -> bool>(_: &vec::Vec0, _: F) { } - - #[inline(always)] - fn canonical_basis_element(_: usize) -> Option> { - None - } -} - -impl Add for vec::Vec0 { - type Output = vec::Vec0; - - #[inline] - fn add(self, _: T) -> vec::Vec0 { - vec::Vec0(PhantomData) - } -} - -impl Sub for vec::Vec0 { - type Output = vec::Vec0; - - #[inline] - fn sub(self, _: T) -> vec::Vec0 { - vec::Vec0(PhantomData) - } -} - -impl + Copy> Neg for vec::Vec0 { - type Output = vec::Vec0; - - #[inline] - fn neg(self) -> vec::Vec0 { - vec::Vec0(PhantomData) - } -} - -impl Dot for vec::Vec0 { - #[inline] - fn dot(&self, _: &vec::Vec0) -> N { - ::zero() - } -} - -impl Mul for vec::Vec0 { - type Output = vec::Vec0; - - #[inline] - fn mul(self, _: T) -> vec::Vec0 { - vec::Vec0(PhantomData) - } -} - -impl Div for vec::Vec0 { - type Output = vec::Vec0; - - #[inline] - fn div(self, _: T) -> vec::Vec0 { - vec::Vec0(PhantomData) - } -} - -impl + Neg> Translation> for vec::Vec0 { - #[inline] - fn translation(&self) -> vec::Vec0 { - *self - } - - #[inline] - fn inv_translation(&self) -> vec::Vec0 { - -*self - } - - #[inline] - fn append_translation_mut(&mut self, t: &vec::Vec0) { - *self = *t + *self; - } - - #[inline] - fn append_translation(&self, t: &vec::Vec0) -> vec::Vec0 { - *t + self - } - - #[inline] - fn prepend_translation_mut(&mut self, t: &vec::Vec0) { - *self = *self + *t; - } - - #[inline] - fn prepend_translation(&self, t: &vec::Vec0) -> vec::Vec0 { - *self + *t - } - - #[inline] - fn set_translation(&mut self, _: vec::Vec0) { - } -} - -impl Norm for vec::Vec0 { - #[inline] - fn sqnorm(&self) -> N { - ::zero() - } - - #[inline] - fn norm(&self) -> N { - ::zero() - } - - #[inline] - fn normalize(&self) -> vec::Vec0 { - ::zero() - } - - #[inline] - fn normalize_mut(&mut self) -> N { - ::zero() - } -} - -impl> ApproxEq for vec::Vec0 { - #[inline] - fn approx_epsilon(_: Option>) -> N { - ApproxEq::approx_epsilon(None::) - } - - fn approx_ulps(_: Option>) -> u32 { - ApproxEq::approx_ulps(None::) - } - - #[inline] - fn approx_eq_eps(&self, _: &vec::Vec0, _: &N) -> bool { - true - } - - #[inline] - fn approx_eq_ulps(&self, _: &vec::Vec0, _: u32) -> bool { - true - } -} - -impl One for vec::Vec0 { - #[inline] - fn one() -> vec::Vec0 { - vec::Vec0(PhantomData) - } -} - -impl FromIterator for vec::Vec0 { - #[inline] - fn from_iter>(_: I) -> vec::Vec0 { - vec::Vec0(PhantomData) - } -} - -impl Bounded for vec::Vec0 { - #[inline] - fn max_value() -> vec::Vec0 { - vec::Vec0(PhantomData) - } - - #[inline] - fn min_value() -> vec::Vec0 { - vec::Vec0(PhantomData) - } -} - -impl Rand for vec::Vec0 { - #[inline] - fn rand(_: &mut R) -> vec::Vec0 { vec::Vec0(PhantomData) } -} diff --git a/src/structs/vec.rs b/src/structs/vec.rs index 3b2339f4..6ac503f1 100644 --- a/src/structs/vec.rs +++ b/src/structs/vec.rs @@ -3,7 +3,6 @@ #![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::marker::PhantomData; use std::mem; use std::slice::{Iter, IterMut}; use std::iter::{Iterator, FromIterator, IntoIterator}; @@ -20,29 +19,6 @@ use structs::pnt::{Pnt1, Pnt2, Pnt3, Pnt4, Pnt5, Pnt6}; 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(pub PhantomData); - -impl Vec0 { - /// Creates a new vector. - #[inline] - pub fn new() -> Vec0 { - Vec0(PhantomData) - } -} - -impl Repeat for Vec0 { - #[inline] - fn repeat(_: N) -> Vec0 { - Vec0(PhantomData) - } -} - /// Vector of dimension 1. /// /// The main differance between a point and a vector is that a vector is not affected by