diff --git a/src/na.rs b/src/na.rs index 5c5f035b..e4fd655d 100644 --- a/src/na.rs +++ b/src/na.rs @@ -45,7 +45,7 @@ pub use structs::{ Mat1, Mat2, Mat3, Mat4, Mat5, Mat6, Rot2, Rot3, Rot4, - Vec0, Vec1, Vec2, Vec3, PVec3, Vec4, Vec5, Vec6 + Vec0, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6 }; // diff --git a/src/structs/iso_macros.rs b/src/structs/iso_macros.rs index 149290d6..0762b685 100644 --- a/src/structs/iso_macros.rs +++ b/src/structs/iso_macros.rs @@ -296,7 +296,7 @@ macro_rules! inv_impl( macro_rules! to_homogeneous_impl( ($t: ident, $th: ident) => ( - impl ToHomogeneous<$th> for $t { + impl ToHomogeneous<$th> for $t { fn to_homogeneous(m: &$t) -> $th { let mut res = ToHomogeneous::to_homogeneous(&m.rotation); diff --git a/src/structs/mat.rs b/src/structs/mat.rs index 57311cbf..0a34d773 100644 --- a/src/structs/mat.rs +++ b/src/structs/mat.rs @@ -17,7 +17,7 @@ mod metal; mod mat_macros; /// Special identity matrix. All its operation are no-ops. -#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Rand, Zero, ToStr)] +#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, Rand, ToStr)] pub struct Identity; impl Identity { diff --git a/src/structs/mat_macros.rs b/src/structs/mat_macros.rs index e8870130..3eb85c34 100644 --- a/src/structs/mat_macros.rs +++ b/src/structs/mat_macros.rs @@ -45,7 +45,7 @@ macro_rules! mat_cast_impl( macro_rules! add_impl( ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + impl> $trhs> for $t { #[inline] fn binop(left: &$t, right: &$t) -> $t { $t::new(left.$comp0 + right.$comp0 $(, left.$compN + right.$compN)*) @@ -56,7 +56,7 @@ macro_rules! add_impl( macro_rules! sub_impl( ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + impl> $trhs> for $t { #[inline] fn binop(left: &$t, right: &$t) -> $t { $t::new(left.$comp0 - right.$comp0 $(, left.$compN - right.$compN)*) @@ -148,7 +148,7 @@ macro_rules! iterable_mut_impl( macro_rules! one_impl( ($t: ident, $value0: expr $(, $valueN: expr)* ) => ( - impl One for $t { + impl One for $t { #[inline] fn one() -> $t { $t::new($value0() $(, $valueN() )*) @@ -472,7 +472,7 @@ macro_rules! approx_eq_impl( macro_rules! to_homogeneous_impl( ($t: ident, $t2: ident, $dim: expr, $dim2: expr) => ( - impl ToHomogeneous<$t2> for $t { + impl ToHomogeneous<$t2> for $t { #[inline] fn to_homogeneous(m: &$t) -> $t2 { let mut res: $t2 = One::one(); @@ -491,7 +491,7 @@ macro_rules! to_homogeneous_impl( macro_rules! from_homogeneous_impl( ($t: ident, $t2: ident, $dim: expr, $dim2: expr) => ( - impl FromHomogeneous<$t2> for $t { + impl FromHomogeneous<$t2> for $t { #[inline] fn from(m: &$t2) -> $t { let mut res: $t = One::one(); @@ -513,7 +513,7 @@ macro_rules! from_homogeneous_impl( macro_rules! outer_impl( ($t: ident, $m: ident) => ( - impl + Zero + Clone> Outer<$m> for $t { + impl + Zero> Outer<$m> for $t { #[inline] fn outer(a: &$t, b: &$t) -> $m { let mut res: $m = Zero::zero(); diff --git a/src/structs/mod.rs b/src/structs/mod.rs index ec263789..e9c2935e 100644 --- a/src/structs/mod.rs +++ b/src/structs/mod.rs @@ -2,7 +2,7 @@ pub use self::dmat::DMat; pub use self::dvec::DVec; -pub use self::vec::{Vec0, Vec1, Vec2, Vec3, PVec3, Vec4, Vec5, Vec6}; +pub use self::vec::{Vec0, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6}; 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}; diff --git a/src/structs/rot_macros.rs b/src/structs/rot_macros.rs index b0d341f0..7b130aa2 100644 --- a/src/structs/rot_macros.rs +++ b/src/structs/rot_macros.rs @@ -68,7 +68,7 @@ macro_rules! rotation_matrix_impl( macro_rules! one_impl( ($t: ident) => ( - impl One for $t { + impl One for $t { #[inline] fn one() -> $t { $t { submat: One::one() } @@ -188,7 +188,7 @@ macro_rules! col_impl( macro_rules! to_homogeneous_impl( ($t: ident, $tm: ident) => ( - impl ToHomogeneous<$tm> for $t { + impl ToHomogeneous<$tm> for $t { #[inline] fn to_homogeneous(m: &$t) -> $tm { ToHomogeneous::to_homogeneous(&m.submat) diff --git a/src/structs/spec/vec0.rs b/src/structs/spec/vec0.rs index 5d0da33b..4530084c 100644 --- a/src/structs/spec/vec0.rs +++ b/src/structs/spec/vec0.rs @@ -97,7 +97,7 @@ impl> Neg> for vec::Vec0 { } } -impl Dot for vec::Vec0 { +impl Dot for vec::Vec0 { #[inline] fn dot(_: &vec::Vec0, _: &vec::Vec0) -> N { Zero::zero() @@ -159,7 +159,7 @@ impl + Neg> Translation> for vec::Vec0 { } } -impl Norm for vec::Vec0 { +impl Norm for vec::Vec0 { #[inline] fn sqnorm(_: &vec::Vec0) -> N { Zero::zero() @@ -198,7 +198,7 @@ impl> ApproxEq for vec::Vec0 { } } -impl One for vec::Vec0 { +impl One for vec::Vec0 { #[inline] fn one() -> vec::Vec0 { vec::Vec0 @@ -212,7 +212,7 @@ impl FromIterator for vec::Vec0 { } } -impl Bounded for vec::Vec0 { +impl Bounded for vec::Vec0 { #[inline] fn max_value() -> vec::Vec0 { vec::Vec0 diff --git a/src/structs/vec.rs b/src/structs/vec.rs index a2976bc0..c7884475 100644 --- a/src/structs/vec.rs +++ b/src/structs/vec.rs @@ -105,9 +105,9 @@ translation_impl!(Vec1) norm_impl!(Vec1, x) approx_eq_impl!(Vec1, x) round_impl!(Vec1, x) -one_impl!(Vec1) +one_impl!(Vec1, x) from_iterator_impl!(Vec1, iterator) -bounded_impl!(Vec1) +bounded_impl!(Vec1, x) iterable_impl!(Vec1, 1) iterable_mut_impl!(Vec1, 1) to_homogeneous_impl!(Vec1, Vec2, y, x) @@ -204,9 +204,9 @@ translation_impl!(Vec2) norm_impl!(Vec2, x, y) approx_eq_impl!(Vec2, x, y) round_impl!(Vec2, x, y) -one_impl!(Vec2) +one_impl!(Vec2, x, y) from_iterator_impl!(Vec2, iterator, iterator) -bounded_impl!(Vec2) +bounded_impl!(Vec2, x, y) iterable_impl!(Vec2, 2) iterable_mut_impl!(Vec2, 2) to_homogeneous_impl!(Vec2, Vec3, z, x, y) @@ -308,9 +308,9 @@ translation_impl!(Vec3) norm_impl!(Vec3, x, y ,z) approx_eq_impl!(Vec3, x, y, z) round_impl!(Vec3, x, y, z) -one_impl!(Vec3) +one_impl!(Vec3, x, y, z) from_iterator_impl!(Vec3, iterator, iterator, iterator) -bounded_impl!(Vec3) +bounded_impl!(Vec3, x, y, z) iterable_impl!(Vec3, 3) iterable_mut_impl!(Vec3, 3) to_homogeneous_impl!(Vec3, Vec4, w, x, y, z) @@ -320,117 +320,6 @@ rotate_impl!(Vec3) transform_impl!(Vec3) -/// Vector of dimension 3 with an extra component for padding. -#[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] -pub struct PVec3 { - /// First component of the vector. - x: N, - /// Second component of the vector. - y: N, - /// Third component of the vector. - z: N, - // Unused component, for padding - priv _unused: N -} - -impl PVec3 { - /// Creates a new 3d vector. - pub fn new(x: N, y: N, z: N) -> PVec3 { - PVec3 { x: x.clone(), y: y, z: z, _unused: x } - } -} - -double_dispatch_binop_decl_trait!(PVec3, PVec3MulRhs) -double_dispatch_binop_decl_trait!(PVec3, PVec3DivRhs) -double_dispatch_binop_decl_trait!(PVec3, PVec3AddRhs) -double_dispatch_binop_decl_trait!(PVec3, PVec3SubRhs) -double_dispatch_cast_decl_trait!(PVec3, PVec3Cast) -mul_redispatch_impl!(PVec3, PVec3MulRhs) -div_redispatch_impl!(PVec3, PVec3DivRhs) -add_redispatch_impl!(PVec3, PVec3AddRhs) -sub_redispatch_impl!(PVec3, PVec3SubRhs) -cast_redispatch_impl!(PVec3, PVec3Cast) -ord_impl!(PVec3, x, y, z) -orderable_impl!(PVec3, x, y, z) -vec_axis_impl!(PVec3, x, y, z) -vec_cast_impl!(PVec3, PVec3Cast, x, y, z) -indexable_impl!(PVec3, 3) -at_fast_impl!(PVec3, 3) -new_repeat_impl!(PVec3, val, x, y, z, _unused) -dim_impl!(PVec3, 3) -container_impl!(PVec3) -// (specialized) basis_impl!(PVec3, 1) -add_impl!(PVec3, PVec3AddRhs, x, y, z) -sub_impl!(PVec3, PVec3SubRhs, x, y, z) -mul_impl!(PVec3, PVec3MulRhs, x, y, z) -div_impl!(PVec3, PVec3DivRhs, x, y, z) -neg_impl!(PVec3, x, y, z) -dot_impl!(PVec3, x, y, z) -scalar_mul_impl!(PVec3, f64, PVec3MulRhs, x, y, z) -scalar_mul_impl!(PVec3, f32, PVec3MulRhs, x, y, z) -scalar_mul_impl!(PVec3, u64, PVec3MulRhs, x, y, z) -scalar_mul_impl!(PVec3, u32, PVec3MulRhs, x, y, z) -scalar_mul_impl!(PVec3, u16, PVec3MulRhs, x, y, z) -scalar_mul_impl!(PVec3, u8, PVec3MulRhs, x, y, z) -scalar_mul_impl!(PVec3, i64, PVec3MulRhs, x, y, z) -scalar_mul_impl!(PVec3, i32, PVec3MulRhs, x, y, z) -scalar_mul_impl!(PVec3, i16, PVec3MulRhs, x, y, z) -scalar_mul_impl!(PVec3, i8, PVec3MulRhs, x, y, z) -scalar_mul_impl!(PVec3, uint, PVec3MulRhs, x, y, z) -scalar_mul_impl!(PVec3, int, PVec3MulRhs, x, y, z) -scalar_div_impl!(PVec3, f64, PVec3DivRhs, x, y, z) -scalar_div_impl!(PVec3, f32, PVec3DivRhs, x, y, z) -scalar_div_impl!(PVec3, u64, PVec3DivRhs, x, y, z) -scalar_div_impl!(PVec3, u32, PVec3DivRhs, x, y, z) -scalar_div_impl!(PVec3, u16, PVec3DivRhs, x, y, z) -scalar_div_impl!(PVec3, u8, PVec3DivRhs, x, y, z) -scalar_div_impl!(PVec3, i64, PVec3DivRhs, x, y, z) -scalar_div_impl!(PVec3, i32, PVec3DivRhs, x, y, z) -scalar_div_impl!(PVec3, i16, PVec3DivRhs, x, y, z) -scalar_div_impl!(PVec3, i8, PVec3DivRhs, x, y, z) -scalar_div_impl!(PVec3, uint, PVec3DivRhs, x, y, z) -scalar_div_impl!(PVec3, int, PVec3DivRhs, x, y, z) -scalar_add_impl!(PVec3, f64, PVec3AddRhs, x, y, z) -scalar_add_impl!(PVec3, f32, PVec3AddRhs, x, y, z) -scalar_add_impl!(PVec3, u64, PVec3AddRhs, x, y, z) -scalar_add_impl!(PVec3, u32, PVec3AddRhs, x, y, z) -scalar_add_impl!(PVec3, u16, PVec3AddRhs, x, y, z) -scalar_add_impl!(PVec3, u8, PVec3AddRhs, x, y, z) -scalar_add_impl!(PVec3, i64, PVec3AddRhs, x, y, z) -scalar_add_impl!(PVec3, i32, PVec3AddRhs, x, y, z) -scalar_add_impl!(PVec3, i16, PVec3AddRhs, x, y, z) -scalar_add_impl!(PVec3, i8, PVec3AddRhs, x, y, z) -scalar_add_impl!(PVec3, uint, PVec3AddRhs, x, y, z) -scalar_add_impl!(PVec3, int, PVec3AddRhs, x, y, z) -scalar_sub_impl!(PVec3, f64, PVec3SubRhs, x, y, z) -scalar_sub_impl!(PVec3, f32, PVec3SubRhs, x, y, z) -scalar_sub_impl!(PVec3, u64, PVec3SubRhs, x, y, z) -scalar_sub_impl!(PVec3, u32, PVec3SubRhs, x, y, z) -scalar_sub_impl!(PVec3, u16, PVec3SubRhs, x, y, z) -scalar_sub_impl!(PVec3, u8, PVec3SubRhs, x, y, z) -scalar_sub_impl!(PVec3, i64, PVec3SubRhs, x, y, z) -scalar_sub_impl!(PVec3, i32, PVec3SubRhs, x, y, z) -scalar_sub_impl!(PVec3, i16, PVec3SubRhs, x, y, z) -scalar_sub_impl!(PVec3, i8, PVec3SubRhs, x, y, z) -scalar_sub_impl!(PVec3, uint, PVec3SubRhs, x, y, z) -scalar_sub_impl!(PVec3, int, PVec3SubRhs, x, y, z) -translation_impl!(PVec3) -norm_impl!(PVec3, x, y, z) -approx_eq_impl!(PVec3, x, y, z) -round_impl!(PVec3, x, y, z) -one_impl!(PVec3) -from_iterator_impl!(PVec3, iterator, iterator, iterator) -bounded_impl!(PVec3) -iterable_impl!(PVec3, 3) -iterable_mut_impl!(PVec3, 3) -to_homogeneous_impl!(PVec3, Vec4, w, x, y, z) -from_homogeneous_impl!(PVec3, Vec4, w, x, y, z) -translate_impl!(PVec3) -rotate_impl!(PVec3) -transform_impl!(PVec3) - - - /// Vector of dimension 4. #[deriving(Eq, Encodable, Decodable, Clone, DeepClone, IterBytes, Rand, Zero, ToStr)] pub struct Vec4 { @@ -523,9 +412,9 @@ translation_impl!(Vec4) norm_impl!(Vec4, x, y, z, w) approx_eq_impl!(Vec4, x, y, z, w) round_impl!(Vec4, x, y, z, w) -one_impl!(Vec4) +one_impl!(Vec4, x, y, z, w) from_iterator_impl!(Vec4, iterator, iterator, iterator, iterator) -bounded_impl!(Vec4) +bounded_impl!(Vec4, x, y, z, w) iterable_impl!(Vec4, 4) iterable_mut_impl!(Vec4, 4) to_homogeneous_impl!(Vec4, Vec5, a, x, y, z, w) @@ -628,9 +517,9 @@ translation_impl!(Vec5) norm_impl!(Vec5, x, y, z, w, a) approx_eq_impl!(Vec5, x, y, z, w, a) round_impl!(Vec5, x, y, z, w, a) -one_impl!(Vec5) +one_impl!(Vec5, x, y, z, w, a) from_iterator_impl!(Vec5, iterator, iterator, iterator, iterator, iterator) -bounded_impl!(Vec5) +bounded_impl!(Vec5, x, y, z, w, a) iterable_impl!(Vec5, 5) iterable_mut_impl!(Vec5, 5) to_homogeneous_impl!(Vec5, Vec6, b, x, y, z, w, a) @@ -735,9 +624,9 @@ translation_impl!(Vec6) norm_impl!(Vec6, x, y, z, w, a, b) approx_eq_impl!(Vec6, x, y, z, w, a, b) round_impl!(Vec6, x, y, z, w, a, b) -one_impl!(Vec6) +one_impl!(Vec6, x, y, z, w, a, b) from_iterator_impl!(Vec6, iterator, iterator, iterator, iterator, iterator, iterator) -bounded_impl!(Vec6) +bounded_impl!(Vec6, x, y, z, w, a, b) iterable_impl!(Vec6, 6) iterable_mut_impl!(Vec6, 6) translate_impl!(Vec6) diff --git a/src/structs/vec_macros.rs b/src/structs/vec_macros.rs index 878da7cb..488997be 100644 --- a/src/structs/vec_macros.rs +++ b/src/structs/vec_macros.rs @@ -277,7 +277,7 @@ macro_rules! basis_impl( macro_rules! add_impl( ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + impl> $trhs> for $t { #[inline] fn binop(left: &$t, right: &$t) -> $t { $t::new(left.$comp0 + right.$comp0 $(, left.$compN + right.$compN)*) @@ -288,7 +288,7 @@ macro_rules! add_impl( macro_rules! sub_impl( ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + impl> $trhs> for $t { #[inline] fn binop(left: &$t, right: &$t) -> $t { $t::new(left.$comp0 - right.$comp0 $(, left.$compN - right.$compN)*) @@ -299,7 +299,7 @@ macro_rules! sub_impl( macro_rules! mul_impl( ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + impl> $trhs> for $t { #[inline] fn binop(left: &$t, right: &$t) -> $t { $t::new(left.$comp0 * right.$comp0 $(, left.$compN * right.$compN)*) @@ -310,7 +310,7 @@ macro_rules! mul_impl( macro_rules! div_impl( ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + impl> $trhs> for $t { #[inline] fn binop(left: &$t, right: &$t) -> $t { $t::new(left.$comp0 / right.$comp0 $(, left.$compN / right.$compN)*) @@ -321,7 +321,7 @@ macro_rules! div_impl( macro_rules! neg_impl( ($t: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> Neg<$t> for $t { + impl> Neg<$t> for $t { #[inline] fn neg(&self) -> $t { $t::new(-self.$comp0 $(, -self.$compN )*) @@ -332,7 +332,7 @@ macro_rules! neg_impl( macro_rules! dot_impl( ($t: ident, $comp0: ident $(,$compN: ident)*) => ( - impl Dot for $t { + impl Dot for $t { #[inline] fn dot(a: &$t, b: &$t) -> N { a.$comp0 * b.$comp0 $(+ a.$compN * b.$compN )* @@ -468,7 +468,7 @@ macro_rules! norm_impl( macro_rules! round_impl( ($t: ident, $comp0: ident $(,$compN: ident)*) => ( - impl Round for $t { + impl Round for $t { fn floor(&self) -> $t { $t::new(self.$comp0.floor() $(, self.$compN.floor())*) } @@ -516,11 +516,14 @@ macro_rules! approx_eq_impl( ) macro_rules! one_impl( - ($t: ident) => ( - impl One for $t { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl One for $t { #[inline] fn one() -> $t { - $t::new_repeat(One::one()) + $t { + $comp0: One::one() + $(, $compN: One::one() )* + } } } ) @@ -528,7 +531,7 @@ macro_rules! one_impl( macro_rules! from_iterator_impl( ($t: ident, $param0: ident $(, $paramN: ident)*) => ( - impl FromIterator for $t { + impl FromIterator for $t { #[inline] fn from_iterator>($param0: &mut I) -> $t { $t::new($param0.next().unwrap() $(, $paramN.next().unwrap())*) @@ -538,16 +541,22 @@ macro_rules! from_iterator_impl( ) macro_rules! bounded_impl( - ($t: ident) => ( - impl Bounded for $t { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl Bounded for $t { #[inline] fn max_value() -> $t { - $t::new_repeat(Bounded::max_value()) + $t { + $comp0: Bounded::max_value() + $(, $compN: Bounded::max_value() )* + } } #[inline] fn min_value() -> $t { - $t::new_repeat(Bounded::min_value()) + $t { + $comp0: Bounded::min_value() + $(, $compN: Bounded::min_value() )* + } } } ) @@ -585,7 +594,7 @@ macro_rules! from_homogeneous_impl( macro_rules! translate_impl( ($t: ident) => ( - impl + Sub> Translate<$t> for $t { + impl + Sub> Translate<$t> for $t { fn translate(&self, other: &$t) -> $t { *other + *self }