From d296bebfac88b67b23632b818aa3d600adde20a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Wed, 26 Nov 2014 14:17:34 +0100 Subject: [PATCH] Replace the double dispatch trick by multidispatch! Fix #38. --- src/lib.rs | 35 -- src/structs/dmat.rs | 192 +++------- src/structs/dvec.rs | 14 +- src/structs/dvec_macros.rs | 142 ++----- src/structs/iso.rs | 32 +- src/structs/iso_macros.rs | 59 +-- src/structs/mat.rs | 765 ++++++++----------------------------- src/structs/mat_macros.rs | 90 ++--- src/structs/metal.rs | 88 ----- src/structs/mod.rs | 14 - src/structs/pnt.rs | 432 +++------------------ src/structs/pnt_macros.rs | 30 +- src/structs/quat.rs | 124 ++---- src/structs/rot.rs | 52 ++- src/structs/rot_macros.rs | 126 ++---- src/structs/spec/mat.rs | 112 +++--- src/structs/vec.rs | 455 ++++------------------ src/structs/vec_macros.rs | 93 +++-- 18 files changed, 687 insertions(+), 2168 deletions(-) delete mode 100644 src/structs/metal.rs diff --git a/src/lib.rs b/src/lib.rs index 3e6a664a..ac7751b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -193,41 +193,6 @@ mod macros; // mod lower_triangular; // mod chol; -/* - * Reexport everything. - */ -/// Traits to work around the language limitations related to operator overloading. -/// -/// The trait names are formed by: -/// -/// * a type name (eg. Vec1, Vec2, Mat3, Mat4, etc.). -/// * the name of a binary operation (eg. Mul, Div, Add, Sub, etc.). -/// * the word `Rhs`. -/// -/// When implemented by the type `T`, the trait makes it possible to overload the binary operator -/// between `T` and the type name given by the trait. -/// -/// # Examples: -/// -/// * `Vec3MulRhs` will allow the overload of the `*` operator between the implementor type and -/// `Vec3`. The `Vec3` being the first argument of the multiplication. -/// * `Mat4DivRhs` will allow the overload of the `/` operator between the implementor type and -/// `Mat4`. The `Mat4` being the first argument of the division. -pub mod overload { - pub use structs::{Vec1MulRhs, Vec2MulRhs, Vec3MulRhs, Vec4MulRhs, Vec5MulRhs, Vec6MulRhs, - Vec1DivRhs, Vec2DivRhs, Vec3DivRhs, Vec4DivRhs, Vec5DivRhs, Vec6DivRhs, - Vec1AddRhs, Vec2AddRhs, Vec3AddRhs, Vec4AddRhs, Vec5AddRhs, Vec6AddRhs, - Vec1SubRhs, Vec2SubRhs, Vec3SubRhs, Vec4SubRhs, Vec5SubRhs, Vec6SubRhs, - Pnt1MulRhs, Pnt2MulRhs, Pnt3MulRhs, Pnt4MulRhs, Pnt5MulRhs, Pnt6MulRhs, - Pnt1DivRhs, Pnt2DivRhs, Pnt3DivRhs, Pnt4DivRhs, Pnt5DivRhs, Pnt6DivRhs, - Pnt1AddRhs, Pnt2AddRhs, Pnt3AddRhs, Pnt4AddRhs, Pnt5AddRhs, Pnt6AddRhs, - Pnt1SubRhs, Pnt2SubRhs, Pnt3SubRhs, Pnt4SubRhs, Pnt5SubRhs, Pnt6SubRhs, - Mat1MulRhs, Mat2MulRhs, Mat3MulRhs, Mat4MulRhs, Mat5MulRhs, Mat6MulRhs, - Mat1DivRhs, Mat2DivRhs, Mat3DivRhs, Mat4DivRhs, Mat5DivRhs, Mat6DivRhs, - Mat1AddRhs, Mat2AddRhs, Mat3AddRhs, Mat4AddRhs, Mat5AddRhs, Mat6AddRhs, - Mat1SubRhs, Mat2SubRhs, Mat3SubRhs, Mat4SubRhs, Mat5SubRhs, Mat6SubRhs}; -} - /// Change the input value to ensure it is on the range `[min, max]`. #[inline(always)] pub fn clamp(val: T, min: T, max: T) -> T { diff --git a/src/structs/dmat.rs b/src/structs/dmat.rs index 15815318..146785ce 100644 --- a/src/structs/dmat.rs +++ b/src/structs/dmat.rs @@ -7,7 +7,7 @@ use std::rand::Rand; use std::rand; use traits::operations::ApproxEq; use std::mem; -use structs::dvec::{DVec, DVecMulRhs}; +use structs::dvec::DVec; use traits::operations::{Inv, Transpose, Mean, Cov}; use traits::structure::{Cast, ColSlice, RowSlice, Diag, Eye, Indexable, Shape, Zero, One, BaseNum}; use std::fmt::{Show, Formatter, Result}; @@ -21,16 +21,6 @@ pub struct DMat { mij: Vec } -double_dispatch_binop_decl_trait!(DMat, DMatMulRhs) -double_dispatch_binop_decl_trait!(DMat, DMatDivRhs) -double_dispatch_binop_decl_trait!(DMat, DMatAddRhs) -double_dispatch_binop_decl_trait!(DMat, DMatSubRhs) - -mul_redispatch_impl!(DMat, DMatMulRhs) -div_redispatch_impl!(DMat, DMatDivRhs) -add_redispatch_impl!(DMat, DMatAddRhs) -sub_redispatch_impl!(DMat, DMatSubRhs) - impl DMat { /// Creates an uninitialized matrix. #[inline] @@ -293,20 +283,20 @@ impl IndexMut<(uint, uint), N> for DMat { } } -impl + Add + Zero> DMatMulRhs> for DMat { - fn binop(left: &DMat, right: &DMat) -> DMat { - assert!(left.ncols == right.nrows); +impl + Add + Zero> Mul, DMat> for DMat { + fn mul(&self, right: &DMat) -> DMat { + assert!(self.ncols == right.nrows); - let mut res = unsafe { DMat::new_uninitialized(left.nrows, right.ncols) }; + let mut res = unsafe { DMat::new_uninitialized(self.nrows, right.ncols) }; - for i in range(0u, left.nrows) { + for i in range(0u, self.nrows) { for j in range(0u, right.ncols) { let mut acc: N = ::zero(); unsafe { - for k in range(0u, left.ncols) { + for k in range(0u, self.ncols) { acc = acc - + left.unsafe_at((i, k)) * right.unsafe_at((k, j)); + + self.unsafe_at((i, k)) * right.unsafe_at((k, j)); } res.unsafe_set((i, j), acc); @@ -318,19 +308,18 @@ impl + Add + Zero> DMatMulRhs> for DMat } } -impl + Mul + Zero> -DMatMulRhs> for DVec { - fn binop(left: &DMat, right: &DVec) -> DVec { - assert!(left.ncols == right.at.len()); +impl + Mul + Zero> Mul, DVec> for DMat { + fn mul(&self, right: &DVec) -> DVec { + assert!(self.ncols == right.at.len()); - let mut res : DVec = unsafe { DVec::new_uninitialized(left.nrows) }; + let mut res : DVec = unsafe { DVec::new_uninitialized(self.nrows) }; - for i in range(0u, left.nrows) { + for i in range(0u, self.nrows) { let mut acc: N = ::zero(); - for j in range(0u, left.ncols) { + for j in range(0u, self.ncols) { unsafe { - acc = acc + left.unsafe_at((i, j)) * right.unsafe_at(j); + acc = acc + self.unsafe_at((i, j)) * right.unsafe_at(j); } } @@ -342,10 +331,9 @@ DMatMulRhs> for DVec { } -impl + Mul + Zero> -DVecMulRhs> for DMat { - fn binop(left: &DVec, right: &DMat) -> DVec { - assert!(right.nrows == left.at.len()); +impl + Mul + Zero> Mul, DVec> for DVec { + fn mul(&self, right: &DMat) -> DVec { + assert!(right.nrows == self.at.len()); let mut res : DVec = unsafe { DVec::new_uninitialized(right.ncols) }; @@ -354,7 +342,7 @@ DVecMulRhs> for DMat { for j in range(0u, right.nrows) { unsafe { - acc = acc + left.unsafe_at(j) * right.unsafe_at((j, i)); + acc = acc + self.unsafe_at(j) * right.unsafe_at((j, i)); } } @@ -516,7 +504,7 @@ impl + Zero + Clone> Mean> for DMat { } } -impl + DMatDivRhs>> Cov> for DMat { +impl + Div> Cov> for DMat { // FIXME: this could be heavily optimized, removing all temporaries by merging loops. fn cov(m: &DMat) -> DMat { assert!(m.nrows > 1); @@ -642,114 +630,46 @@ impl Show for DMat { } } -macro_rules! scalar_mul_impl ( - ($n: ident) => ( - impl DMatMulRhs<$n, DMat<$n>> for $n { - #[inline] - fn binop(left: &DMat<$n>, right: &$n) -> DMat<$n> { - DMat { - nrows: left.nrows, - ncols: left.ncols, - mij: left.mij.iter().map(|a| *a * *right).collect() - } - } +impl> Mul> for DMat { + #[inline] + fn mul(&self, right: &N) -> DMat { + DMat { + nrows: self.nrows, + ncols: self.ncols, + mij: self.mij.iter().map(|a| *a * *right).collect() } - ) -) + } +} -macro_rules! scalar_div_impl ( - ($n: ident) => ( - impl DMatDivRhs<$n, DMat<$n>> for $n { - #[inline] - fn binop(left: &DMat<$n>, right: &$n) -> DMat<$n> { - DMat { - nrows: left.nrows, - ncols: left.ncols, - mij: left.mij.iter().map(|a| *a / *right).collect() - } - } +impl> Div> for DMat { + #[inline] + fn div(&self, right: &N) -> DMat { + DMat { + nrows: self.nrows, + ncols: self.ncols, + mij: self.mij.iter().map(|a| *a / *right).collect() } - ) -) + } +} -macro_rules! scalar_add_impl ( - ($n: ident) => ( - impl DMatAddRhs<$n, DMat<$n>> for $n { - #[inline] - fn binop(left: &DMat<$n>, right: &$n) -> DMat<$n> { - DMat { - nrows: left.nrows, - ncols: left.ncols, - mij: left.mij.iter().map(|a| *a + *right).collect() - } - } +impl> Add> for DMat { + #[inline] + fn add(&self, right: &N) -> DMat { + DMat { + nrows: self.nrows, + ncols: self.ncols, + mij: self.mij.iter().map(|a| *a + *right).collect() } - ) -) + } +} -macro_rules! scalar_sub_impl ( - ($n: ident) => ( - impl DMatSubRhs<$n, DMat<$n>> for $n { - #[inline] - fn binop(left: &DMat<$n>, right: &$n) -> DMat<$n> { - DMat { - nrows: left.nrows, - ncols: left.ncols, - mij: left.mij.iter().map(|a| *a - *right).collect() - } - } +impl> Sub> for DMat { + #[inline] + fn sub(&self, right: &N) -> DMat { + DMat { + nrows: self.nrows, + ncols: self.ncols, + mij: self.mij.iter().map(|a| *a - *right).collect() } - ) -) - -scalar_mul_impl!(f64) -scalar_mul_impl!(f32) -scalar_mul_impl!(u64) -scalar_mul_impl!(u32) -scalar_mul_impl!(u16) -scalar_mul_impl!(u8) -scalar_mul_impl!(i64) -scalar_mul_impl!(i32) -scalar_mul_impl!(i16) -scalar_mul_impl!(i8) -scalar_mul_impl!(uint) -scalar_mul_impl!(int) - -scalar_div_impl!(f64) -scalar_div_impl!(f32) -scalar_div_impl!(u64) -scalar_div_impl!(u32) -scalar_div_impl!(u16) -scalar_div_impl!(u8) -scalar_div_impl!(i64) -scalar_div_impl!(i32) -scalar_div_impl!(i16) -scalar_div_impl!(i8) -scalar_div_impl!(uint) -scalar_div_impl!(int) - -scalar_add_impl!(f64) -scalar_add_impl!(f32) -scalar_add_impl!(u64) -scalar_add_impl!(u32) -scalar_add_impl!(u16) -scalar_add_impl!(u8) -scalar_add_impl!(i64) -scalar_add_impl!(i32) -scalar_add_impl!(i16) -scalar_add_impl!(i8) -scalar_add_impl!(uint) -scalar_add_impl!(int) - -scalar_sub_impl!(f64) -scalar_sub_impl!(f32) -scalar_sub_impl!(u64) -scalar_sub_impl!(u32) -scalar_sub_impl!(u16) -scalar_sub_impl!(u8) -scalar_sub_impl!(i64) -scalar_sub_impl!(i32) -scalar_sub_impl!(i16) -scalar_sub_impl!(i8) -scalar_sub_impl!(uint) -scalar_sub_impl!(int) + } +} diff --git a/src/structs/dvec.rs b/src/structs/dvec.rs index e32594d7..44a508f6 100644 --- a/src/structs/dvec.rs +++ b/src/structs/dvec.rs @@ -77,7 +77,7 @@ impl FromIterator for DVec { } -dvec_impl!(DVec, DVecMulRhs, DVecDivRhs, DVecAddRhs, DVecSubRhs) +dvec_impl!(DVec) /// Stack-allocated, dynamically sized vector with a maximum size of 1. pub struct DVec1 { @@ -85,7 +85,7 @@ pub struct DVec1 { dim: uint } -small_dvec_impl!(DVec1, 1, DVec1MulRhs, DVec1DivRhs, DVec1AddRhs, DVec1SubRhs, 0) +small_dvec_impl!(DVec1, 1, 0) small_dvec_from_impl!(DVec1, 1, ::zero()) @@ -95,7 +95,7 @@ pub struct DVec2 { dim: uint } -small_dvec_impl!(DVec2, 2, DVec2MulRhs, DVec2DivRhs, DVec2AddRhs, DVec2SubRhs, 0, 1) +small_dvec_impl!(DVec2, 2, 0, 1) small_dvec_from_impl!(DVec2, 2, ::zero(), ::zero()) @@ -105,7 +105,7 @@ pub struct DVec3 { dim: uint } -small_dvec_impl!(DVec3, 3, DVec3MulRhs, DVec3DivRhs, DVec3AddRhs, DVec3SubRhs, 0, 1, 2) +small_dvec_impl!(DVec3, 3, 0, 1, 2) small_dvec_from_impl!(DVec3, 3, ::zero(), ::zero(), ::zero()) @@ -115,7 +115,7 @@ pub struct DVec4 { dim: uint } -small_dvec_impl!(DVec4, 4, DVec4MulRhs, DVec4DivRhs, DVec4AddRhs, DVec4SubRhs, 0, 1, 2, 3) +small_dvec_impl!(DVec4, 4, 0, 1, 2, 3) small_dvec_from_impl!(DVec4, 4, ::zero(), ::zero(), ::zero(), ::zero()) @@ -125,7 +125,7 @@ pub struct DVec5 { dim: uint } -small_dvec_impl!(DVec5, 5, DVec5MulRhs, DVec5DivRhs, DVec5AddRhs, DVec5SubRhs, 0, 1, 2, 3, 4) +small_dvec_impl!(DVec5, 5, 0, 1, 2, 3, 4) small_dvec_from_impl!(DVec5, 5, ::zero(), ::zero(), ::zero(), ::zero(), ::zero()) @@ -135,5 +135,5 @@ pub struct DVec6 { dim: uint } -small_dvec_impl!(DVec6, 6, DVec6MulRhs, DVec6DivRhs, DVec6AddRhs, DVec6SubRhs, 0, 1, 2, 3, 4, 5) +small_dvec_impl!(DVec6, 6, 0, 1, 2, 3, 4, 5) small_dvec_from_impl!(DVec6, 6, ::zero(), ::zero(), ::zero(), ::zero(), ::zero(), ::zero()) diff --git a/src/structs/dvec_macros.rs b/src/structs/dvec_macros.rs index 5a6d9b3c..2f8db2b1 100644 --- a/src/structs/dvec_macros.rs +++ b/src/structs/dvec_macros.rs @@ -1,17 +1,7 @@ #![macro_escape] macro_rules! dvec_impl( - ($dvec: ident, $mul: ident, $div: ident, $add: ident, $sub: ident) => ( - double_dispatch_binop_decl_trait!($dvec, $mul) - double_dispatch_binop_decl_trait!($dvec, $div) - double_dispatch_binop_decl_trait!($dvec, $add) - double_dispatch_binop_decl_trait!($dvec, $sub) - - mul_redispatch_impl!($dvec, $mul) - div_redispatch_impl!($dvec, $div) - add_redispatch_impl!($dvec, $add) - sub_redispatch_impl!($dvec, $sub) - + ($dvec: ident) => ( impl $dvec { /// Builds a vector filled with zeros. /// @@ -132,7 +122,7 @@ macro_rules! dvec_impl( } } - impl + $mul>> $dvec { + impl> $dvec { /// Computes the canonical basis for the given dimension. A canonical basis is a set of /// vectors, mutually orthogonal, with all its component equal to 0.0 except one which is equal /// to 1.0. @@ -186,35 +176,35 @@ macro_rules! dvec_impl( } } - impl + Zero> $mul> for $dvec { + impl + Zero> Mul<$dvec, $dvec> for $dvec { #[inline] - fn binop(left: &$dvec, right: &$dvec) -> $dvec { - assert!(left.len() == right.len()); - FromIterator::from_iter(left.as_slice().iter().zip(right.as_slice().iter()).map(|(a, b)| *a * *b)) + fn mul(&self, right: &$dvec) -> $dvec { + assert!(self.len() == right.len()); + FromIterator::from_iter(self.as_slice().iter().zip(right.as_slice().iter()).map(|(a, b)| *a * *b)) } } - impl + Zero> $div> for $dvec { + impl + Zero> Div<$dvec, $dvec> for $dvec { #[inline] - fn binop(left: &$dvec, right: &$dvec) -> $dvec { - assert!(left.len() == right.len()); - FromIterator::from_iter(left.as_slice().iter().zip(right.as_slice().iter()).map(|(a, b)| *a / *b)) + fn div(&self, right: &$dvec) -> $dvec { + assert!(self.len() == right.len()); + FromIterator::from_iter(self.as_slice().iter().zip(right.as_slice().iter()).map(|(a, b)| *a / *b)) } } - impl + Zero> $add> for $dvec { + impl + Zero> Add<$dvec, $dvec> for $dvec { #[inline] - fn binop(left: &$dvec, right: &$dvec) -> $dvec { - assert!(left.len() == right.len()); - FromIterator::from_iter(left.as_slice().iter().zip(right.as_slice().iter()).map(|(a, b)| *a + *b)) + fn add(&self, right: &$dvec) -> $dvec { + assert!(self.len() == right.len()); + FromIterator::from_iter(self.as_slice().iter().zip(right.as_slice().iter()).map(|(a, b)| *a + *b)) } } - impl + Zero> $sub> for $dvec { + impl + Zero> Sub<$dvec, $dvec> for $dvec { #[inline] - fn binop(left: &$dvec, right: &$dvec) -> $dvec { - assert!(left.len() == right.len()); - FromIterator::from_iter(left.as_slice().iter().zip(right.as_slice().iter()).map(|(a, b)| *a - *b)) + fn sub(&self, right: &$dvec) -> $dvec { + assert!(self.len() == right.len()); + FromIterator::from_iter(self.as_slice().iter().zip(right.as_slice().iter()).map(|(a, b)| *a - *b)) } } @@ -293,106 +283,38 @@ macro_rules! dvec_impl( } } - dvec_scalar_mul_impl!($dvec, f64, $mul) - dvec_scalar_mul_impl!($dvec, f32, $mul) - dvec_scalar_mul_impl!($dvec, u64, $mul) - dvec_scalar_mul_impl!($dvec, u32, $mul) - dvec_scalar_mul_impl!($dvec, u16, $mul) - dvec_scalar_mul_impl!($dvec, u8, $mul) - dvec_scalar_mul_impl!($dvec, i64, $mul) - dvec_scalar_mul_impl!($dvec, i32, $mul) - dvec_scalar_mul_impl!($dvec, i16, $mul) - dvec_scalar_mul_impl!($dvec, i8, $mul) - dvec_scalar_mul_impl!($dvec, uint, $mul) - dvec_scalar_mul_impl!($dvec, int, $mul) - - dvec_scalar_div_impl!($dvec, f64, $div) - dvec_scalar_div_impl!($dvec, f32, $div) - dvec_scalar_div_impl!($dvec, u64, $div) - dvec_scalar_div_impl!($dvec, u32, $div) - dvec_scalar_div_impl!($dvec, u16, $div) - dvec_scalar_div_impl!($dvec, u8, $div) - dvec_scalar_div_impl!($dvec, i64, $div) - dvec_scalar_div_impl!($dvec, i32, $div) - dvec_scalar_div_impl!($dvec, i16, $div) - dvec_scalar_div_impl!($dvec, i8, $div) - dvec_scalar_div_impl!($dvec, uint, $div) - dvec_scalar_div_impl!($dvec, int, $div) - - dvec_scalar_add_impl!($dvec, f64, $add) - dvec_scalar_add_impl!($dvec, f32, $add) - dvec_scalar_add_impl!($dvec, u64, $add) - dvec_scalar_add_impl!($dvec, u32, $add) - dvec_scalar_add_impl!($dvec, u16, $add) - dvec_scalar_add_impl!($dvec, u8, $add) - dvec_scalar_add_impl!($dvec, i64, $add) - dvec_scalar_add_impl!($dvec, i32, $add) - dvec_scalar_add_impl!($dvec, i16, $add) - dvec_scalar_add_impl!($dvec, i8, $add) - dvec_scalar_add_impl!($dvec, uint, $add) - dvec_scalar_add_impl!($dvec, int, $add) - - dvec_scalar_sub_impl!($dvec, f64, $sub) - dvec_scalar_sub_impl!($dvec, f32, $sub) - dvec_scalar_sub_impl!($dvec, u64, $sub) - dvec_scalar_sub_impl!($dvec, u32, $sub) - dvec_scalar_sub_impl!($dvec, u16, $sub) - dvec_scalar_sub_impl!($dvec, u8, $sub) - dvec_scalar_sub_impl!($dvec, i64, $sub) - dvec_scalar_sub_impl!($dvec, i32, $sub) - dvec_scalar_sub_impl!($dvec, i16, $sub) - dvec_scalar_sub_impl!($dvec, i8, $sub) - dvec_scalar_sub_impl!($dvec, uint, $sub) - dvec_scalar_sub_impl!($dvec, int, $sub) - ) -) - -macro_rules! dvec_scalar_mul_impl ( - ($dvec: ident, $n: ident, $mul: ident) => ( - impl $mul<$n, $dvec<$n>> for $n { + impl + Zero> Mul> for $dvec { #[inline] - fn binop(left: &$dvec<$n>, right: &$n) -> $dvec<$n> { - FromIterator::from_iter(left.as_slice().iter().map(|a| *a * *right)) + fn mul(&self, right: &N) -> $dvec { + FromIterator::from_iter(self.as_slice().iter().map(|a| *a * *right)) } } - ) -) -macro_rules! dvec_scalar_div_impl ( - ($dvec: ident, $n: ident, $div: ident) => ( - impl $div<$n, $dvec<$n>> for $n { + impl + Zero> Div> for $dvec { #[inline] - fn binop(left: &$dvec<$n>, right: &$n) -> $dvec<$n> { - FromIterator::from_iter(left.as_slice().iter().map(|a| *a / *right)) + fn div(&self, right: &N) -> $dvec { + FromIterator::from_iter(self.as_slice().iter().map(|a| *a / *right)) } } - ) -) -macro_rules! dvec_scalar_add_impl ( - ($dvec: ident, $n: ident, $add: ident) => ( - impl $add<$n, $dvec<$n>> for $n { + impl + Zero> Add> for $dvec { #[inline] - fn binop(left: &$dvec<$n>, right: &$n) -> $dvec<$n> { - FromIterator::from_iter(left.as_slice().iter().map(|a| *a + *right)) + fn add(&self, right: &N) -> $dvec { + FromIterator::from_iter(self.as_slice().iter().map(|a| *a + *right)) } } - ) -) -macro_rules! dvec_scalar_sub_impl ( - ($dvec: ident, $n: ident, $sub: ident) => ( - impl $sub<$n, $dvec<$n>> for $n { + impl + Zero> Sub> for $dvec { #[inline] - fn binop(left: &$dvec<$n>, right: &$n) -> $dvec<$n> { - FromIterator::from_iter(left.as_slice().iter().map(|a| *a - *right)) + fn sub(&self, right: &N) -> $dvec { + FromIterator::from_iter(self.as_slice().iter().map(|a| *a - *right)) } } ) ) macro_rules! small_dvec_impl ( - ($dvec: ident, $dim: expr, $mul: ident, $div: ident, $add: ident, $sub: ident $(,$idx: expr)*) => ( + ($dvec: ident, $dim: expr $(,$idx: expr)*) => ( impl $dvec { #[inline] pub fn len(&self) -> uint { @@ -428,7 +350,7 @@ macro_rules! small_dvec_impl ( } } - dvec_impl!($dvec, $mul, $div, $add, $sub) + dvec_impl!($dvec) ) ) diff --git a/src/structs/iso.rs b/src/structs/iso.rs index 3ee23e57..5a13e649 100644 --- a/src/structs/iso.rs +++ b/src/structs/iso.rs @@ -10,7 +10,7 @@ use traits::geometry::{RotationMatrix, Rotation, Rotate, AbsoluteRotate, Transfo Translate, Translation, ToHomogeneous}; use structs::vec::{Vec1, Vec2, Vec3, Vec4}; -use structs::pnt::{Pnt2, Pnt3, Pnt4, Pnt2MulRhs, Pnt3MulRhs, Pnt4MulRhs}; +use structs::pnt::{Pnt2, Pnt3, Pnt4}; use structs::rot::{Rot2, Rot3, Rot4}; @@ -93,8 +93,6 @@ impl Iso4 { } iso_impl!(Iso2, Rot2, Vec2, Vec1) -double_dispatch_binop_decl_trait!(Iso2, Iso2MulRhs) -mul_redispatch_impl!(Iso2, Iso2MulRhs) rotation_matrix_impl!(Iso2, Rot2, Vec2, Vec1) rotation_impl!(Iso2, Rot2, Vec1) dim_impl!(Iso2, 2) @@ -104,18 +102,16 @@ rand_impl!(Iso2) approx_eq_impl!(Iso2) to_homogeneous_impl!(Iso2, Mat3) inv_impl!(Iso2) -transform_impl!(Iso2TransformRhs, Iso2, Vec2, Pnt2) +transform_impl!(Iso2, Pnt2) transformation_impl!(Iso2) rotate_impl!(Iso2, Vec2) translation_impl!(Iso2, Vec2) translate_impl!(Iso2, Pnt2) -iso_mul_iso_impl!(Iso2, Iso2MulRhs) -iso_mul_pnt_impl!(Iso2, Pnt2, Iso2MulRhs) -pnt_mul_iso_impl!(Iso2, Pnt2, Pnt2MulRhs) +iso_mul_iso_impl!(Iso2) +iso_mul_pnt_impl!(Iso2, Pnt2) +pnt_mul_iso_impl!(Iso2, Pnt2) iso_impl!(Iso3, Rot3, Vec3, Vec3) -double_dispatch_binop_decl_trait!(Iso3, Iso3MulRhs) -mul_redispatch_impl!(Iso3, Iso3MulRhs) rotation_matrix_impl!(Iso3, Rot3, Vec3, Vec3) rotation_impl!(Iso3, Rot3, Vec3) dim_impl!(Iso3, 3) @@ -125,18 +121,16 @@ rand_impl!(Iso3) approx_eq_impl!(Iso3) to_homogeneous_impl!(Iso3, Mat4) inv_impl!(Iso3) -transform_impl!(Iso3TransformRhs, Iso3, Vec3, Pnt3) +transform_impl!(Iso3, Pnt3) transformation_impl!(Iso3) rotate_impl!(Iso3, Vec3) translation_impl!(Iso3, Vec3) translate_impl!(Iso3, Pnt3) -iso_mul_iso_impl!(Iso3, Iso3MulRhs) -iso_mul_pnt_impl!(Iso3, Pnt3, Iso3MulRhs) -pnt_mul_iso_impl!(Iso3, Pnt3, Pnt3MulRhs) +iso_mul_iso_impl!(Iso3) +iso_mul_pnt_impl!(Iso3, Pnt3) +pnt_mul_iso_impl!(Iso3, Pnt3) // iso_impl!(Iso4, Rot4, Vec4, Vec4) -double_dispatch_binop_decl_trait!(Iso4, Iso4MulRhs) -mul_redispatch_impl!(Iso4, Iso4MulRhs) // rotation_matrix_impl!(Iso4, Rot4, Vec4, Vec4) // rotation_impl!(Iso4, Rot4, Vec4) dim_impl!(Iso4, 4) @@ -146,11 +140,11 @@ absolute_rotate_impl!(Iso4, Vec4) approx_eq_impl!(Iso4) to_homogeneous_impl!(Iso4, Mat5) inv_impl!(Iso4) -transform_impl!(Iso4TransformRhs, Iso4, Vec4, Pnt4) +transform_impl!(Iso4, Pnt4) transformation_impl!(Iso4) rotate_impl!(Iso4, Vec4) translation_impl!(Iso4, Vec4) translate_impl!(Iso4, Pnt4) -iso_mul_iso_impl!(Iso4, Iso4MulRhs) -iso_mul_pnt_impl!(Iso4, Pnt4, Iso4MulRhs) -pnt_mul_iso_impl!(Iso4, Pnt4, Pnt4MulRhs) +iso_mul_iso_impl!(Iso4) +iso_mul_pnt_impl!(Iso4, Pnt4) +pnt_mul_iso_impl!(Iso4, Pnt4) diff --git a/src/structs/iso_macros.rs b/src/structs/iso_macros.rs index f3380019..86f1b95b 100644 --- a/src/structs/iso_macros.rs +++ b/src/structs/iso_macros.rs @@ -60,35 +60,35 @@ macro_rules! one_impl( ) macro_rules! iso_mul_iso_impl( - ($t: ident, $tmul: ident) => ( - impl $tmul> for $t { + ($t: ident) => ( + impl Mul<$t, $t> for $t { #[inline] - fn binop(left: &$t, right: &$t) -> $t { + fn mul(&self, right: &$t) -> $t { $t::new_with_rotmat( - left.translation + left.rotation * right.translation, - left.rotation * right.rotation) + self.translation + self.rotation * right.translation, + self.rotation * right.rotation) } } ) ) macro_rules! iso_mul_pnt_impl( - ($t: ident, $tv: ident, $tmul: ident) => ( - impl $tmul> for $tv { + ($t: ident, $tv: ident) => ( + impl Mul<$tv, $tv> for $t { #[inline] - fn binop(left: &$t, right: &$tv) -> $tv { - left.rotation * *right + left.translation + fn mul(&self, right: &$tv) -> $tv { + self.rotation * *right + self.translation } } ) ) macro_rules! pnt_mul_iso_impl( - ($t: ident, $tv: ident, $tmul: ident) => ( - impl $tmul> for $t { + ($t: ident, $tv: ident) => ( + impl Mul<$t, $tv> for $tv { #[inline] - fn binop(left: &$tv, right: &$t) -> $tv { - (*left + right.translation) * right.rotation + fn mul(&self, right: &$t) -> $tv { + (*self + right.translation) * right.rotation } } ) @@ -254,37 +254,16 @@ macro_rules! transformation_impl( ) macro_rules! transform_impl( - ($trhs: ident, $t: ident, $tv: ident, $tp: ident) => ( - /* - * FIXME: we use the double dispatch trick here so that we can transform vectors _and_ - * points. Remove this as soon as rust supports multidispatch. - */ - pub trait $trhs { - fn transform(left: &$t, right: &Self) -> Self; - fn inv_transform(left: &$t, right: &Self) -> Self; - } - - impl> Transform for $t { - #[inline(always)] - fn transform(&self, other: &V) -> V { - $trhs::transform(self, other) - } - - #[inline(always)] - fn inv_transform(&self, other: &V) -> V { - $trhs::inv_transform(self, other) - } - } - - impl $trhs for $tp { + ($t: ident, $tp: ident) => ( + impl Transform<$tp> for $t { #[inline] - fn transform(t: &$t, p: &$tp) -> $tp { - t.rotation.transform(p) + t.translation + fn transform(&self, p: &$tp) -> $tp { + self.rotation.transform(p) + self.translation } #[inline] - fn inv_transform(t: &$t, p: &$tp) -> $tp { - t.rotation.inv_transform(&(*p - t.translation)) + fn inv_transform(&self, p: &$tp) -> $tp { + self.rotation.inv_transform(&(*p - self.translation)) } } ) diff --git a/src/structs/mat.rs b/src/structs/mat.rs index b6d6f763..186ddf4f 100644 --- a/src/structs/mat.rs +++ b/src/structs/mat.rs @@ -5,9 +5,8 @@ use std::mem; use traits::operations::ApproxEq; use std::slice::{Items, MutItems}; -use structs::vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6, - Vec1MulRhs, Vec4MulRhs, Vec5MulRhs, Vec6MulRhs}; -use structs::pnt::{Pnt1, Pnt4, Pnt5, Pnt6, Pnt1MulRhs, Pnt4MulRhs, Pnt5MulRhs, Pnt6MulRhs}; +use structs::vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6}; +use structs::pnt::{Pnt1, Pnt4, Pnt5, Pnt6}; use structs::dvec::{DVec1, DVec2, DVec3, DVec4, DVec5, DVec6}; use traits::structure::{Cast, Row, Col, Iterable, IterableMut, Dim, Indexable, @@ -37,74 +36,15 @@ pub struct Mat1 { eye_impl!(Mat1, 1, m11) -double_dispatch_binop_decl_trait!(Mat1, Mat1MulRhs) -double_dispatch_binop_decl_trait!(Mat1, Mat1DivRhs) -double_dispatch_binop_decl_trait!(Mat1, Mat1AddRhs) -double_dispatch_binop_decl_trait!(Mat1, Mat1SubRhs) -double_dispatch_cast_decl_trait!(Mat1, Mat1Cast) -mul_redispatch_impl!(Mat1, Mat1MulRhs) -div_redispatch_impl!(Mat1, Mat1DivRhs) -add_redispatch_impl!(Mat1, Mat1AddRhs) -sub_redispatch_impl!(Mat1, Mat1SubRhs) -cast_redispatch_impl!(Mat1, Mat1Cast) mat_impl!(Mat1, m11) as_array_impl!(Mat1, 1) -mat_cast_impl!(Mat1, Mat1Cast, m11) -add_impl!(Mat1, Mat1AddRhs, m11) -sub_impl!(Mat1, Mat1SubRhs, m11) - -mat_mul_scalar_impl!(Mat1, f64, Mat1MulRhs, m11) -mat_mul_scalar_impl!(Mat1, f32, Mat1MulRhs, m11) -mat_mul_scalar_impl!(Mat1, i64, Mat1MulRhs, m11) -mat_mul_scalar_impl!(Mat1, i32, Mat1MulRhs, m11) -mat_mul_scalar_impl!(Mat1, i16, Mat1MulRhs, m11) -mat_mul_scalar_impl!(Mat1, i8, Mat1MulRhs, m11) -mat_mul_scalar_impl!(Mat1, u64, Mat1MulRhs, m11) -mat_mul_scalar_impl!(Mat1, u32, Mat1MulRhs, m11) -mat_mul_scalar_impl!(Mat1, u16, Mat1MulRhs, m11) -mat_mul_scalar_impl!(Mat1, u8, Mat1MulRhs, m11) -mat_mul_scalar_impl!(Mat1, uint, Mat1MulRhs, m11) -mat_mul_scalar_impl!(Mat1, int, Mat1MulRhs, m11) - -mat_div_scalar_impl!(Mat1, f64, Mat1DivRhs, m11) -mat_div_scalar_impl!(Mat1, f32, Mat1DivRhs, m11) -mat_div_scalar_impl!(Mat1, i64, Mat1DivRhs, m11) -mat_div_scalar_impl!(Mat1, i32, Mat1DivRhs, m11) -mat_div_scalar_impl!(Mat1, i16, Mat1DivRhs, m11) -mat_div_scalar_impl!(Mat1, i8, Mat1DivRhs, m11) -mat_div_scalar_impl!(Mat1, u64, Mat1DivRhs, m11) -mat_div_scalar_impl!(Mat1, u32, Mat1DivRhs, m11) -mat_div_scalar_impl!(Mat1, u16, Mat1DivRhs, m11) -mat_div_scalar_impl!(Mat1, u8, Mat1DivRhs, m11) -mat_div_scalar_impl!(Mat1, uint, Mat1DivRhs, m11) -mat_div_scalar_impl!(Mat1, int, Mat1DivRhs, m11) - -mat_add_scalar_impl!(Mat1, f64, Mat1AddRhs, m11) -mat_add_scalar_impl!(Mat1, f32, Mat1AddRhs, m11) -mat_add_scalar_impl!(Mat1, i64, Mat1AddRhs, m11) -mat_add_scalar_impl!(Mat1, i32, Mat1AddRhs, m11) -mat_add_scalar_impl!(Mat1, i16, Mat1AddRhs, m11) -mat_add_scalar_impl!(Mat1, i8, Mat1AddRhs, m11) -mat_add_scalar_impl!(Mat1, u64, Mat1AddRhs, m11) -mat_add_scalar_impl!(Mat1, u32, Mat1AddRhs, m11) -mat_add_scalar_impl!(Mat1, u16, Mat1AddRhs, m11) -mat_add_scalar_impl!(Mat1, u8, Mat1AddRhs, m11) -mat_add_scalar_impl!(Mat1, uint, Mat1AddRhs, m11) -mat_add_scalar_impl!(Mat1, int, Mat1AddRhs, m11) - -mat_sub_scalar_impl!(Mat1, f64, Mat1SubRhs, m11) -mat_sub_scalar_impl!(Mat1, f32, Mat1SubRhs, m11) -mat_sub_scalar_impl!(Mat1, i64, Mat1SubRhs, m11) -mat_sub_scalar_impl!(Mat1, i32, Mat1SubRhs, m11) -mat_sub_scalar_impl!(Mat1, i16, Mat1SubRhs, m11) -mat_sub_scalar_impl!(Mat1, i8, Mat1SubRhs, m11) -mat_sub_scalar_impl!(Mat1, u64, Mat1SubRhs, m11) -mat_sub_scalar_impl!(Mat1, u32, Mat1SubRhs, m11) -mat_sub_scalar_impl!(Mat1, u16, Mat1SubRhs, m11) -mat_sub_scalar_impl!(Mat1, u8, Mat1SubRhs, m11) -mat_sub_scalar_impl!(Mat1, uint, Mat1SubRhs, m11) -mat_sub_scalar_impl!(Mat1, int, Mat1SubRhs, m11) - +mat_cast_impl!(Mat1, m11) +add_impl!(Mat1, m11) +sub_impl!(Mat1, m11) +scalar_add_impl!(Mat1, m11) +scalar_sub_impl!(Mat1, m11) +scalar_mul_impl!(Mat1, m11) +scalar_div_impl!(Mat1, m11) absolute_impl!(Mat1, m11) zero_impl!(Mat1, m11) one_impl!(Mat1, ::one) @@ -114,11 +54,11 @@ at_fast_impl!(Mat1, 1) dim_impl!(Mat1, 1) indexable_impl!(Mat1, 1) index_impl!(Mat1, 1) -mat_mul_mat_impl!(Mat1, Mat1MulRhs, 1) -mat_mul_vec_impl!(Mat1, Vec1, Mat1MulRhs, 1, ::zero) -vec_mul_mat_impl!(Mat1, Vec1, Vec1MulRhs, 1, ::zero) -mat_mul_pnt_impl!(Mat1, Pnt1, Mat1MulRhs, 1, Orig::orig) -pnt_mul_mat_impl!(Mat1, Pnt1, Pnt1MulRhs, 1, Orig::orig) +mat_mul_mat_impl!(Mat1, 1) +mat_mul_vec_impl!(Mat1, Vec1, 1, ::zero) +vec_mul_mat_impl!(Mat1, Vec1, 1, ::zero) +mat_mul_pnt_impl!(Mat1, Pnt1, 1, Orig::orig) +pnt_mul_mat_impl!(Mat1, Pnt1, 1, Orig::orig) // (specialized) inv_impl!(Mat1, 1) transpose_impl!(Mat1, 1) approx_eq_impl!(Mat1) @@ -141,81 +81,22 @@ pub struct Mat2 { eye_impl!(Mat2, 2, m11, m22) -double_dispatch_binop_decl_trait!(Mat2, Mat2MulRhs) -double_dispatch_binop_decl_trait!(Mat2, Mat2DivRhs) -double_dispatch_binop_decl_trait!(Mat2, Mat2AddRhs) -double_dispatch_binop_decl_trait!(Mat2, Mat2SubRhs) -double_dispatch_cast_decl_trait!(Mat2, Mat2Cast) -mul_redispatch_impl!(Mat2, Mat2MulRhs) -div_redispatch_impl!(Mat2, Mat2DivRhs) -add_redispatch_impl!(Mat2, Mat2AddRhs) -sub_redispatch_impl!(Mat2, Mat2SubRhs) -cast_redispatch_impl!(Mat2, Mat2Cast) mat_impl!(Mat2, m11, m12, m21, m22) as_array_impl!(Mat2, 2) -mat_cast_impl!(Mat2, Mat2Cast, m11, m12, - m21, m22) -add_impl!(Mat2, Mat2AddRhs, m11, m12, m21, m22) -sub_impl!(Mat2, Mat2SubRhs, m11, m12, m21, m22) - -mat_mul_scalar_impl!(Mat2, f64, Mat2MulRhs, m11, m12, m21, m22) -mat_mul_scalar_impl!(Mat2, f32, Mat2MulRhs, m11, m12, m21, m22) -mat_mul_scalar_impl!(Mat2, i64, Mat2MulRhs, m11, m12, m21, m22) -mat_mul_scalar_impl!(Mat2, i32, Mat2MulRhs, m11, m12, m21, m22) -mat_mul_scalar_impl!(Mat2, i16, Mat2MulRhs, m11, m12, m21, m22) -mat_mul_scalar_impl!(Mat2, i8, Mat2MulRhs, m11, m12, m21, m22) -mat_mul_scalar_impl!(Mat2, u64, Mat2MulRhs, m11, m12, m21, m22) -mat_mul_scalar_impl!(Mat2, u32, Mat2MulRhs, m11, m12, m21, m22) -mat_mul_scalar_impl!(Mat2, u16, Mat2MulRhs, m11, m12, m21, m22) -mat_mul_scalar_impl!(Mat2, u8, Mat2MulRhs, m11, m12, m21, m22) -mat_mul_scalar_impl!(Mat2, uint, Mat2MulRhs, m11, m12, m21, m22) -mat_mul_scalar_impl!(Mat2, int, Mat2MulRhs, m11, m12, m21, m22) - -mat_div_scalar_impl!(Mat2, f64, Mat2DivRhs, m11, m12, m21, m22) -mat_div_scalar_impl!(Mat2, f32, Mat2DivRhs, m11, m12, m21, m22) -mat_div_scalar_impl!(Mat2, i64, Mat2DivRhs, m11, m12, m21, m22) -mat_div_scalar_impl!(Mat2, i32, Mat2DivRhs, m11, m12, m21, m22) -mat_div_scalar_impl!(Mat2, i16, Mat2DivRhs, m11, m12, m21, m22) -mat_div_scalar_impl!(Mat2, i8, Mat2DivRhs, m11, m12, m21, m22) -mat_div_scalar_impl!(Mat2, u64, Mat2DivRhs, m11, m12, m21, m22) -mat_div_scalar_impl!(Mat2, u32, Mat2DivRhs, m11, m12, m21, m22) -mat_div_scalar_impl!(Mat2, u16, Mat2DivRhs, m11, m12, m21, m22) -mat_div_scalar_impl!(Mat2, u8, Mat2DivRhs, m11, m12, m21, m22) -mat_div_scalar_impl!(Mat2, uint, Mat2DivRhs, m11, m12, m21, m22) -mat_div_scalar_impl!(Mat2, int, Mat2DivRhs, m11, m12, m21, m22) - -mat_add_scalar_impl!(Mat2, f64, Mat2AddRhs, m11, m12, m21, m22) -mat_add_scalar_impl!(Mat2, f32, Mat2AddRhs, m11, m12, m21, m22) -mat_add_scalar_impl!(Mat2, i64, Mat2AddRhs, m11, m12, m21, m22) -mat_add_scalar_impl!(Mat2, i32, Mat2AddRhs, m11, m12, m21, m22) -mat_add_scalar_impl!(Mat2, i16, Mat2AddRhs, m11, m12, m21, m22) -mat_add_scalar_impl!(Mat2, i8, Mat2AddRhs, m11, m12, m21, m22) -mat_add_scalar_impl!(Mat2, u64, Mat2AddRhs, m11, m12, m21, m22) -mat_add_scalar_impl!(Mat2, u32, Mat2AddRhs, m11, m12, m21, m22) -mat_add_scalar_impl!(Mat2, u16, Mat2AddRhs, m11, m12, m21, m22) -mat_add_scalar_impl!(Mat2, u8, Mat2AddRhs, m11, m12, m21, m22) -mat_add_scalar_impl!(Mat2, uint, Mat2AddRhs, m11, m12, m21, m22) -mat_add_scalar_impl!(Mat2, int, Mat2AddRhs, m11, m12, m21, m22) - -mat_sub_scalar_impl!(Mat2, f64, Mat2SubRhs, m11, m12, m21, m22) -mat_sub_scalar_impl!(Mat2, f32, Mat2SubRhs, m11, m12, m21, m22) -mat_sub_scalar_impl!(Mat2, i64, Mat2SubRhs, m11, m12, m21, m22) -mat_sub_scalar_impl!(Mat2, i32, Mat2SubRhs, m11, m12, m21, m22) -mat_sub_scalar_impl!(Mat2, i16, Mat2SubRhs, m11, m12, m21, m22) -mat_sub_scalar_impl!(Mat2, i8, Mat2SubRhs, m11, m12, m21, m22) -mat_sub_scalar_impl!(Mat2, u64, Mat2SubRhs, m11, m12, m21, m22) -mat_sub_scalar_impl!(Mat2, u32, Mat2SubRhs, m11, m12, m21, m22) -mat_sub_scalar_impl!(Mat2, u16, Mat2SubRhs, m11, m12, m21, m22) -mat_sub_scalar_impl!(Mat2, u8, Mat2SubRhs, m11, m12, m21, m22) -mat_sub_scalar_impl!(Mat2, uint, Mat2SubRhs, m11, m12, m21, m22) -mat_sub_scalar_impl!(Mat2, int, Mat2SubRhs, m11, m12, m21, m22) - +mat_cast_impl!(Mat2, m11, m12, + m21, m22) +add_impl!(Mat2, m11, m12, m21, m22) +sub_impl!(Mat2, m11, m12, m21, m22) +scalar_add_impl!(Mat2, m11, m12, m21, m22) +scalar_sub_impl!(Mat2, m11, m12, m21, m22) +scalar_mul_impl!(Mat2, m11, m12, m21, m22) +scalar_div_impl!(Mat2, m11, m12, m21, m22) absolute_impl!(Mat2, m11, m12, m21, m22) zero_impl!(Mat2, m11, m12, m21, m22) -one_impl!(Mat2, ::one, ::zero, +one_impl!(Mat2, ::one, ::zero, ::zero, ::one) iterable_impl!(Mat2, 2) iterable_mut_impl!(Mat2, 2) @@ -249,85 +130,43 @@ pub struct Mat3 { eye_impl!(Mat3, 3, m11, m22, m33) -double_dispatch_binop_decl_trait!(Mat3, Mat3MulRhs) -double_dispatch_binop_decl_trait!(Mat3, Mat3DivRhs) -double_dispatch_binop_decl_trait!(Mat3, Mat3AddRhs) -double_dispatch_binop_decl_trait!(Mat3, Mat3SubRhs) -double_dispatch_cast_decl_trait!(Mat3, Mat3Cast) -mul_redispatch_impl!(Mat3, Mat3MulRhs) -div_redispatch_impl!(Mat3, Mat3DivRhs) -add_redispatch_impl!(Mat3, Mat3AddRhs) -sub_redispatch_impl!(Mat3, Mat3SubRhs) -cast_redispatch_impl!(Mat3, Mat3Cast) mat_impl!(Mat3, m11, m12, m13, m21, m22, m23, m31, m32, m33) as_array_impl!(Mat3, 3) -mat_cast_impl!(Mat3, Mat3Cast, m11, m12, m13, - m21, m22, m23, - m31, m32, m33) -add_impl!(Mat3, Mat3AddRhs, +mat_cast_impl!(Mat3, m11, m12, m13, + m21, m22, m23, + m31, m32, m33) +add_impl!(Mat3, m11, m12, m13, m21, m22, m23, m31, m32, m33 ) -sub_impl!(Mat3, Mat3SubRhs, +sub_impl!(Mat3, + m11, m12, m13, + m21, m22, m23, + m31, m32, m33 +) +scalar_add_impl!(Mat3, + m11, m12, m13, + m21, m22, m23, + m31, m32, m33 +) +scalar_sub_impl!(Mat3, + m11, m12, m13, + m21, m22, m23, + m31, m32, m33 +) +scalar_mul_impl!(Mat3, + m11, m12, m13, + m21, m22, m23, + m31, m32, m33 +) +scalar_div_impl!(Mat3, m11, m12, m13, m21, m22, m23, m31, m32, m33 ) -mat_mul_scalar_impl!(Mat3, f64, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_mul_scalar_impl!(Mat3, f32, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_mul_scalar_impl!(Mat3, i64, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_mul_scalar_impl!(Mat3, i32, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_mul_scalar_impl!(Mat3, i16, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_mul_scalar_impl!(Mat3, i8, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_mul_scalar_impl!(Mat3, u64, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_mul_scalar_impl!(Mat3, u32, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_mul_scalar_impl!(Mat3, u16, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_mul_scalar_impl!(Mat3, u8, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_mul_scalar_impl!(Mat3, uint, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_mul_scalar_impl!(Mat3, int, Mat3MulRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) - -mat_div_scalar_impl!(Mat3, f64, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_div_scalar_impl!(Mat3, f32, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_div_scalar_impl!(Mat3, i64, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_div_scalar_impl!(Mat3, i32, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_div_scalar_impl!(Mat3, i16, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_div_scalar_impl!(Mat3, i8, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_div_scalar_impl!(Mat3, u64, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_div_scalar_impl!(Mat3, u32, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_div_scalar_impl!(Mat3, u16, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_div_scalar_impl!(Mat3, u8, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_div_scalar_impl!(Mat3, uint, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_div_scalar_impl!(Mat3, int, Mat3DivRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) - -mat_add_scalar_impl!(Mat3, f64, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_add_scalar_impl!(Mat3, f32, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_add_scalar_impl!(Mat3, i64, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_add_scalar_impl!(Mat3, i32, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_add_scalar_impl!(Mat3, i16, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_add_scalar_impl!(Mat3, i8, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_add_scalar_impl!(Mat3, u64, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_add_scalar_impl!(Mat3, u32, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_add_scalar_impl!(Mat3, u16, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_add_scalar_impl!(Mat3, u8, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_add_scalar_impl!(Mat3, uint, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_add_scalar_impl!(Mat3, int, Mat3AddRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) - -mat_sub_scalar_impl!(Mat3, f64, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_sub_scalar_impl!(Mat3, f32, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_sub_scalar_impl!(Mat3, i64, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_sub_scalar_impl!(Mat3, i32, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_sub_scalar_impl!(Mat3, i16, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_sub_scalar_impl!(Mat3, i8, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_sub_scalar_impl!(Mat3, u64, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_sub_scalar_impl!(Mat3, u32, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_sub_scalar_impl!(Mat3, u16, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_sub_scalar_impl!(Mat3, u8, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_sub_scalar_impl!(Mat3, uint, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) -mat_sub_scalar_impl!(Mat3, int, Mat3SubRhs, m11, m12, m13, m21, m22, m23, m31, m32, m33) - absolute_impl!(Mat3, m11, m12, m13, m21, m22, m23, @@ -338,8 +177,8 @@ zero_impl!(Mat3, m21, m22, m23, m31, m32, m33 ) -one_impl!(Mat3, ::one , ::zero, ::zero, - ::zero, ::one , ::zero, +one_impl!(Mat3, ::one , ::zero, ::zero, + ::zero, ::one , ::zero, ::zero, ::zero, ::one) iterable_impl!(Mat3, 3) iterable_mut_impl!(Mat3, 3) @@ -374,16 +213,6 @@ pub struct Mat4 { eye_impl!(Mat4, 4, m11, m22, m33, m44) -double_dispatch_binop_decl_trait!(Mat4, Mat4MulRhs) -double_dispatch_binop_decl_trait!(Mat4, Mat4DivRhs) -double_dispatch_binop_decl_trait!(Mat4, Mat4AddRhs) -double_dispatch_binop_decl_trait!(Mat4, Mat4SubRhs) -double_dispatch_cast_decl_trait!(Mat4, Mat4Cast) -mul_redispatch_impl!(Mat4, Mat4MulRhs) -div_redispatch_impl!(Mat4, Mat4DivRhs) -add_redispatch_impl!(Mat4, Mat4AddRhs) -sub_redispatch_impl!(Mat4, Mat4SubRhs) -cast_redispatch_impl!(Mat4, Mat4Cast) mat_impl!(Mat4, m11, m12, m13, m14, m21, m22, m23, m24, @@ -391,117 +220,48 @@ mat_impl!(Mat4, m41, m42, m43, m44 ) as_array_impl!(Mat4, 4) -mat_cast_impl!(Mat4, Mat4Cast, +mat_cast_impl!(Mat4, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44 ) -add_impl!(Mat4, Mat4AddRhs, +add_impl!(Mat4, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44 ) -sub_impl!(Mat4, Mat4SubRhs, +sub_impl!(Mat4, + m11, m12, m13, m14, + m21, m22, m23, m24, + m31, m32, m33, m34, + m41, m42, m43, m44 +) +scalar_add_impl!(Mat4, + m11, m12, m13, m14, + m21, m22, m23, m24, + m31, m32, m33, m34, + m41, m42, m43, m44 +) +scalar_sub_impl!(Mat4, + m11, m12, m13, m14, + m21, m22, m23, m24, + m31, m32, m33, m34, + m41, m42, m43, m44 +) +scalar_mul_impl!(Mat4, + m11, m12, m13, m14, + m21, m22, m23, m24, + m31, m32, m33, m34, + m41, m42, m43, m44 +) +scalar_div_impl!(Mat4, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44 ) - -mat_mul_scalar_impl!(Mat4, f64, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_mul_scalar_impl!(Mat4, f32, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_mul_scalar_impl!(Mat4, i64, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_mul_scalar_impl!(Mat4, i32, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_mul_scalar_impl!(Mat4, i16, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_mul_scalar_impl!(Mat4, i8, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_mul_scalar_impl!(Mat4, u32, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_mul_scalar_impl!(Mat4, u16, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_mul_scalar_impl!(Mat4, u8, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_mul_scalar_impl!(Mat4, uint, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_mul_scalar_impl!(Mat4, int, Mat4MulRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) - -mat_div_scalar_impl!(Mat4, f64, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_div_scalar_impl!(Mat4, f32, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_div_scalar_impl!(Mat4, i64, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_div_scalar_impl!(Mat4, i32, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_div_scalar_impl!(Mat4, i16, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_div_scalar_impl!(Mat4, i8, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_div_scalar_impl!(Mat4, u32, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_div_scalar_impl!(Mat4, u16, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_div_scalar_impl!(Mat4, u8, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_div_scalar_impl!(Mat4, uint, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_div_scalar_impl!(Mat4, int, Mat4DivRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) - -mat_add_scalar_impl!(Mat4, f64, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_add_scalar_impl!(Mat4, f32, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_add_scalar_impl!(Mat4, i64, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_add_scalar_impl!(Mat4, i32, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_add_scalar_impl!(Mat4, i16, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_add_scalar_impl!(Mat4, i8, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_add_scalar_impl!(Mat4, u32, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_add_scalar_impl!(Mat4, u16, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_add_scalar_impl!(Mat4, u8, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_add_scalar_impl!(Mat4, uint, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_add_scalar_impl!(Mat4, int, Mat4AddRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) - -mat_sub_scalar_impl!(Mat4, f64, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_sub_scalar_impl!(Mat4, f32, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_sub_scalar_impl!(Mat4, i64, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_sub_scalar_impl!(Mat4, i32, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_sub_scalar_impl!(Mat4, i16, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_sub_scalar_impl!(Mat4, i8, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_sub_scalar_impl!(Mat4, u32, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_sub_scalar_impl!(Mat4, u16, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_sub_scalar_impl!(Mat4, u8, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_sub_scalar_impl!(Mat4, uint, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) -mat_sub_scalar_impl!(Mat4, int, Mat4SubRhs, m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, - m41, m42, m43, m44) - absolute_impl!(Mat4, m11, m12, m13, m14, m21, m22, m23, m24, @@ -524,11 +284,11 @@ dim_impl!(Mat4, 4) indexable_impl!(Mat4, 4) index_impl!(Mat4, 4) at_fast_impl!(Mat4, 4) -mat_mul_mat_impl!(Mat4, Mat4MulRhs, 4) -mat_mul_vec_impl!(Mat4, Vec4, Mat4MulRhs, 4, ::zero) -vec_mul_mat_impl!(Mat4, Vec4, Vec4MulRhs, 4, ::zero) -mat_mul_pnt_impl!(Mat4, Pnt4, Mat4MulRhs, 4, Orig::orig) -pnt_mul_mat_impl!(Mat4, Pnt4, Pnt4MulRhs, 4, Orig::orig) +mat_mul_mat_impl!(Mat4, 4) +mat_mul_vec_impl!(Mat4, Vec4, 4, ::zero) +vec_mul_mat_impl!(Mat4, Vec4, 4, ::zero) +mat_mul_pnt_impl!(Mat4, Pnt4, 4, Orig::orig) +pnt_mul_mat_impl!(Mat4, Pnt4, 4, Orig::orig) inv_impl!(Mat4, 4) transpose_impl!(Mat4, 4) approx_eq_impl!(Mat4) @@ -554,16 +314,6 @@ pub struct Mat5 { eye_impl!(Mat5, 5, m11, m22, m33, m44, m55) -double_dispatch_binop_decl_trait!(Mat5, Mat5MulRhs) -double_dispatch_binop_decl_trait!(Mat5, Mat5DivRhs) -double_dispatch_binop_decl_trait!(Mat5, Mat5AddRhs) -double_dispatch_binop_decl_trait!(Mat5, Mat5SubRhs) -double_dispatch_cast_decl_trait!(Mat5, Mat5Cast) -mul_redispatch_impl!(Mat5, Mat5MulRhs) -div_redispatch_impl!(Mat5, Mat5DivRhs) -add_redispatch_impl!(Mat5, Mat5AddRhs) -sub_redispatch_impl!(Mat5, Mat5SubRhs) -cast_redispatch_impl!(Mat5, Mat5Cast) mat_impl!(Mat5, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, @@ -572,7 +322,7 @@ mat_impl!(Mat5, m51, m52, m53, m54, m55 ) as_array_impl!(Mat5, 5) -mat_cast_impl!(Mat5, Mat5Cast, +mat_cast_impl!(Mat5, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, m31, m32, m33, m34, m35, @@ -600,131 +350,59 @@ one_impl!(Mat5, ::zero, ::zero, ::zero, ::one , ::zero, ::zero, ::zero, ::zero, ::zero, ::one ) -add_impl!(Mat5, Mat5AddRhs, +add_impl!(Mat5, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55 ) -sub_impl!(Mat5, Mat5SubRhs, +sub_impl!(Mat5, + m11, m12, m13, m14, m15, + m21, m22, m23, m24, m25, + m31, m32, m33, m34, m35, + m41, m42, m43, m44, m45, + m51, m52, m53, m54, m55 +) +scalar_add_impl!(Mat5, + m11, m12, m13, m14, m15, + m21, m22, m23, m24, m25, + m31, m32, m33, m34, m35, + m41, m42, m43, m44, m45, + m51, m52, m53, m54, m55 +) +scalar_sub_impl!(Mat5, + m11, m12, m13, m14, m15, + m21, m22, m23, m24, m25, + m31, m32, m33, m34, m35, + m41, m42, m43, m44, m45, + m51, m52, m53, m54, m55 +) +scalar_mul_impl!(Mat5, + m11, m12, m13, m14, m15, + m21, m22, m23, m24, m25, + m31, m32, m33, m34, m35, + m41, m42, m43, m44, m45, + m51, m52, m53, m54, m55 +) +scalar_div_impl!(Mat5, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55 ) -mat_mul_scalar_impl!(Mat5, f64, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_mul_scalar_impl!(Mat5, f32, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_mul_scalar_impl!(Mat5, i64, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_mul_scalar_impl!(Mat5, i32, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_mul_scalar_impl!(Mat5, i16, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_mul_scalar_impl!(Mat5, i8, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_mul_scalar_impl!(Mat5, u64, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_mul_scalar_impl!(Mat5, u32, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_mul_scalar_impl!(Mat5, u16, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_mul_scalar_impl!(Mat5, u8, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_mul_scalar_impl!(Mat5, uint, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_mul_scalar_impl!(Mat5, int, Mat5MulRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) - -mat_div_scalar_impl!(Mat5, f64, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_div_scalar_impl!(Mat5, f32, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_div_scalar_impl!(Mat5, i64, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_div_scalar_impl!(Mat5, i32, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_div_scalar_impl!(Mat5, i16, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_div_scalar_impl!(Mat5, i8, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_div_scalar_impl!(Mat5, u64, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_div_scalar_impl!(Mat5, u32, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_div_scalar_impl!(Mat5, u16, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_div_scalar_impl!(Mat5, u8, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_div_scalar_impl!(Mat5, uint, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_div_scalar_impl!(Mat5, int, Mat5DivRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) - -mat_add_scalar_impl!(Mat5, f64, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_add_scalar_impl!(Mat5, f32, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_add_scalar_impl!(Mat5, i64, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_add_scalar_impl!(Mat5, i32, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_add_scalar_impl!(Mat5, i16, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_add_scalar_impl!(Mat5, i8, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_add_scalar_impl!(Mat5, u64, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_add_scalar_impl!(Mat5, u32, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_add_scalar_impl!(Mat5, u16, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_add_scalar_impl!(Mat5, u8, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_add_scalar_impl!(Mat5, uint, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_add_scalar_impl!(Mat5, int, Mat5AddRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) - -mat_sub_scalar_impl!(Mat5, f64, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_sub_scalar_impl!(Mat5, f32, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_sub_scalar_impl!(Mat5, i64, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_sub_scalar_impl!(Mat5, i32, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_sub_scalar_impl!(Mat5, i16, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_sub_scalar_impl!(Mat5, i8, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_sub_scalar_impl!(Mat5, u64, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_sub_scalar_impl!(Mat5, u32, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_sub_scalar_impl!(Mat5, u16, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_sub_scalar_impl!(Mat5, u8, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_sub_scalar_impl!(Mat5, uint, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) -mat_sub_scalar_impl!(Mat5, int, Mat5SubRhs, m11, m12, m13, m14, m15, m21, m22, m23, m24, m25, - m31, m32, m33, m34, m35, m41, m42, m43, m44, m45, m51, m52, m53, m54, m55) - iterable_impl!(Mat5, 5) iterable_mut_impl!(Mat5, 5) dim_impl!(Mat5, 5) indexable_impl!(Mat5, 5) index_impl!(Mat5, 5) at_fast_impl!(Mat5, 5) -mat_mul_mat_impl!(Mat5, Mat5MulRhs, 5) -mat_mul_vec_impl!(Mat5, Vec5, Mat5MulRhs, 5, ::zero) -vec_mul_mat_impl!(Mat5, Vec5, Vec5MulRhs, 5, ::zero) -mat_mul_pnt_impl!(Mat5, Pnt5, Mat5MulRhs, 5, Orig::orig) -pnt_mul_mat_impl!(Mat5, Pnt5, Pnt5MulRhs, 5, Orig::orig) +mat_mul_mat_impl!(Mat5, 5) +mat_mul_vec_impl!(Mat5, Vec5, 5, ::zero) +vec_mul_mat_impl!(Mat5, Vec5, 5, ::zero) +mat_mul_pnt_impl!(Mat5, Pnt5, 5, Orig::orig) +pnt_mul_mat_impl!(Mat5, Pnt5, 5, Orig::orig) inv_impl!(Mat5, 5) transpose_impl!(Mat5, 5) approx_eq_impl!(Mat5) @@ -751,16 +429,6 @@ pub struct Mat6 { eye_impl!(Mat6, 6, m11, m22, m33, m44, m55, m66) -double_dispatch_binop_decl_trait!(Mat6, Mat6MulRhs) -double_dispatch_binop_decl_trait!(Mat6, Mat6DivRhs) -double_dispatch_binop_decl_trait!(Mat6, Mat6AddRhs) -double_dispatch_binop_decl_trait!(Mat6, Mat6SubRhs) -double_dispatch_cast_decl_trait!(Mat6, Mat6Cast) -mul_redispatch_impl!(Mat6, Mat6MulRhs) -div_redispatch_impl!(Mat6, Mat6DivRhs) -add_redispatch_impl!(Mat6, Mat6AddRhs) -sub_redispatch_impl!(Mat6, Mat6SubRhs) -cast_redispatch_impl!(Mat6, Mat6Cast) mat_impl!(Mat6, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, @@ -770,7 +438,7 @@ mat_impl!(Mat6, m61, m62, m63, m64, m65, m66 ) as_array_impl!(Mat6, 6) -mat_cast_impl!(Mat6, Mat6Cast, +mat_cast_impl!(Mat6, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, m31, m32, m33, m34, m35, m36, @@ -778,7 +446,7 @@ mat_cast_impl!(Mat6, Mat6Cast, m51, m52, m53, m54, m55, m56, m61, m62, m63, m64, m65, m66 ) -add_impl!(Mat6, Mat6AddRhs, +add_impl!(Mat6, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, m31, m32, m33, m34, m35, m36, @@ -786,7 +454,39 @@ add_impl!(Mat6, Mat6AddRhs, m51, m52, m53, m54, m55, m56, m61, m62, m63, m64, m65, m66 ) -sub_impl!(Mat6, Mat6SubRhs, +sub_impl!(Mat6, + m11, m12, m13, m14, m15, m16, + m21, m22, m23, m24, m25, m26, + m31, m32, m33, m34, m35, m36, + m41, m42, m43, m44, m45, m46, + m51, m52, m53, m54, m55, m56, + m61, m62, m63, m64, m65, m66 +) +scalar_add_impl!(Mat6, + m11, m12, m13, m14, m15, m16, + m21, m22, m23, m24, m25, m26, + m31, m32, m33, m34, m35, m36, + m41, m42, m43, m44, m45, m46, + m51, m52, m53, m54, m55, m56, + m61, m62, m63, m64, m65, m66 +) +scalar_sub_impl!(Mat6, + m11, m12, m13, m14, m15, m16, + m21, m22, m23, m24, m25, m26, + m31, m32, m33, m34, m35, m36, + m41, m42, m43, m44, m45, m46, + m51, m52, m53, m54, m55, m56, + m61, m62, m63, m64, m65, m66 +) +scalar_mul_impl!(Mat6, + m11, m12, m13, m14, m15, m16, + m21, m22, m23, m24, m25, m26, + m31, m32, m33, m34, m35, m36, + m41, m42, m43, m44, m45, m46, + m51, m52, m53, m54, m55, m56, + m61, m62, m63, m64, m65, m66 +) +scalar_div_impl!(Mat6, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, m31, m32, m33, m34, m35, m36, @@ -794,155 +494,6 @@ sub_impl!(Mat6, Mat6SubRhs, m51, m52, m53, m54, m55, m56, m61, m62, m63, m64, m65, m66 ) - -mat_mul_scalar_impl!(Mat6, f64, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_mul_scalar_impl!(Mat6, f32, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_mul_scalar_impl!(Mat6, i64, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_mul_scalar_impl!(Mat6, i32, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_mul_scalar_impl!(Mat6, i16, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_mul_scalar_impl!(Mat6, i8, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_mul_scalar_impl!(Mat6, u64, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_mul_scalar_impl!(Mat6, u32, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_mul_scalar_impl!(Mat6, u16, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_mul_scalar_impl!(Mat6, u8, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_mul_scalar_impl!(Mat6, uint, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_mul_scalar_impl!(Mat6, int, Mat6MulRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) - -mat_div_scalar_impl!(Mat6, f64, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_div_scalar_impl!(Mat6, f32, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_div_scalar_impl!(Mat6, i64, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_div_scalar_impl!(Mat6, i32, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_div_scalar_impl!(Mat6, i16, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_div_scalar_impl!(Mat6, i8, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_div_scalar_impl!(Mat6, u64, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_div_scalar_impl!(Mat6, u32, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_div_scalar_impl!(Mat6, u16, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_div_scalar_impl!(Mat6, u8, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_div_scalar_impl!(Mat6, uint, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_div_scalar_impl!(Mat6, int, Mat6DivRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) - -mat_add_scalar_impl!(Mat6, f64, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_add_scalar_impl!(Mat6, f32, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_add_scalar_impl!(Mat6, i64, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_add_scalar_impl!(Mat6, i32, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_add_scalar_impl!(Mat6, i16, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_add_scalar_impl!(Mat6, i8, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_add_scalar_impl!(Mat6, u64, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_add_scalar_impl!(Mat6, u32, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_add_scalar_impl!(Mat6, u16, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_add_scalar_impl!(Mat6, u8, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_add_scalar_impl!(Mat6, uint, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_add_scalar_impl!(Mat6, int, Mat6AddRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) - -mat_sub_scalar_impl!(Mat6, f64, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_sub_scalar_impl!(Mat6, f32, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_sub_scalar_impl!(Mat6, i64, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_sub_scalar_impl!(Mat6, i32, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_sub_scalar_impl!(Mat6, i16, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_sub_scalar_impl!(Mat6, i8, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_sub_scalar_impl!(Mat6, u64, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_sub_scalar_impl!(Mat6, u32, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_sub_scalar_impl!(Mat6, u16, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_sub_scalar_impl!(Mat6, u8, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_sub_scalar_impl!(Mat6, uint, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) -mat_sub_scalar_impl!(Mat6, int, Mat6SubRhs, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, - m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, - m61, m62, m63, m64, m65, m66) - absolute_impl!(Mat6, m11, m12, m13, m14, m15, m16, m21, m22, m23, m24, m25, m26, m31, m32, m33, m34, m35, m36, m41, m42, m43, m44, m45, m46, m51, m52, m53, m54, m55, m56, m61, m62, m63, m64, m65, m66) @@ -965,11 +516,11 @@ dim_impl!(Mat6, 6) indexable_impl!(Mat6, 6) index_impl!(Mat6, 6) at_fast_impl!(Mat6, 6) -mat_mul_mat_impl!(Mat6, Mat6MulRhs, 6) -mat_mul_vec_impl!(Mat6, Vec6, Mat6MulRhs, 6, ::zero) -vec_mul_mat_impl!(Mat6, Vec6, Vec6MulRhs, 6, ::zero) -mat_mul_pnt_impl!(Mat6, Pnt6, Mat6MulRhs, 6, Orig::orig) -pnt_mul_mat_impl!(Mat6, Pnt6, Pnt6MulRhs, 6, Orig::orig) +mat_mul_mat_impl!(Mat6, 6) +mat_mul_vec_impl!(Mat6, Vec6, 6, ::zero) +vec_mul_mat_impl!(Mat6, Vec6, 6, ::zero) +mat_mul_pnt_impl!(Mat6, Pnt6, 6, Orig::orig) +pnt_mul_mat_impl!(Mat6, Pnt6, 6, Orig::orig) inv_impl!(Mat6, 6) transpose_impl!(Mat6, 6) approx_eq_impl!(Mat6) diff --git a/src/structs/mat_macros.rs b/src/structs/mat_macros.rs index d539a6cc..974b7039 100644 --- a/src/structs/mat_macros.rs +++ b/src/structs/mat_macros.rs @@ -76,10 +76,10 @@ macro_rules! at_fast_impl( ) macro_rules! mat_cast_impl( - ($t: ident, $tcast: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $tcast for $t { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Cast<$t> for $t { #[inline] - fn to(v: $t) -> $t { + fn from(v: $t) -> $t { $t::new(Cast::from(v.$comp0.clone()) $(, Cast::from(v.$compN.clone()))*) } } @@ -87,55 +87,55 @@ macro_rules! mat_cast_impl( ) macro_rules! add_impl( - ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Add<$t, $t> for $t { #[inline] - fn binop(left: &$t, right: &$t) -> $t { - $t::new(left.$comp0 + right.$comp0 $(, left.$compN + right.$compN)*) + fn add(&self, right: &$t) -> $t { + $t::new(self.$comp0 + right.$comp0 $(, self.$compN + right.$compN)*) } } ) ) macro_rules! sub_impl( - ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Sub<$t, $t> for $t { #[inline] - fn binop(left: &$t, right: &$t) -> $t { - $t::new(left.$comp0 - right.$comp0 $(, left.$compN - right.$compN)*) + fn sub(&self, right: &$t) -> $t { + $t::new(self.$comp0 - right.$comp0 $(, self.$compN - right.$compN)*) } } ) ) macro_rules! mat_mul_scalar_impl( - ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl $trhs<$n, $t<$n>> for $n { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Mul> for N { #[inline] - fn binop(left: &$t<$n>, right: &$n) -> $t<$n> { - $t::new(left.$comp0 * *right $(, left.$compN * *right)*) + fn mul(&self, right: &N) -> $t { + $t::new(self.$comp0 * *right $(, self.$compN * *right)*) } } ) ) macro_rules! mat_div_scalar_impl( - ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl $trhs<$n, $t<$n>> for $n { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Div> for $t { #[inline] - fn binop(left: &$t<$n>, right: &$n) -> $t<$n> { - $t::new(left.$comp0 / *right $(, left.$compN / *right)*) + fn div(&self, right: &N) -> $t { + $t::new(self.$comp0 / *right $(, self.$compN / *right)*) } } ) ) macro_rules! mat_add_scalar_impl( - ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl $trhs<$n, $t<$n>> for $n { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Add> for $t { #[inline] - fn binop(left: &$t<$n>, right: &$n) -> $t<$n> { - $t::new(left.$comp0 + *right $(, left.$compN + *right)*) + fn add(&self, right: &N) -> $t { + $t::new(self.$comp0 + *right $(, self.$compN + *right)*) } } ) @@ -143,10 +143,10 @@ macro_rules! mat_add_scalar_impl( macro_rules! eye_impl( - ($t: ident, $ndim: expr, $($comp_diagN: ident),+) => ( + ($t: ident, $dim: expr, $($comp_diagN: ident),+) => ( impl Eye for $t { fn new_identity(dim: uint) -> $t { - assert!(dim == $ndim); + assert!(dim == $dim); let mut eye: $t = ::zero(); $(eye.$comp_diagN = ::one();)+ eye @@ -156,11 +156,11 @@ macro_rules! eye_impl( ) macro_rules! mat_sub_scalar_impl( - ($t: ident, $n: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl $trhs<$n, $t<$n>> for $n { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl Sub> for $t { #[inline] - fn binop(left: &$t<$n>, right: &$n) -> $t<$n> { - $t::new(left.$comp0 - *right $(, left.$compN - *right)*) + fn sub(self, right: &N) -> $t { + $t::new(self.$comp0 - *right $(, self.$compN - *right)*) } } ) @@ -425,10 +425,10 @@ macro_rules! diag_impl( ) macro_rules! mat_mul_mat_impl( - ($t: ident, $trhs: ident, $dim: expr) => ( - impl $trhs> for $t { + ($t: ident, $dim: expr) => ( + impl Mul<$t, $t> for $t { #[inline] - fn binop(left: &$t, right: &$t) -> $t { + fn mul(&self, right: &$t) -> $t { // careful! we need to comute other * self here (self is the rhs). let mut res: $t = ::zero(); @@ -438,7 +438,7 @@ macro_rules! mat_mul_mat_impl( unsafe { for k in range(0u, $dim) { - acc = acc + left.at_fast((i, k)) * right.at_fast((k, j)); + acc = acc + self.at_fast((i, k)) * right.at_fast((k, j)); } res.set_fast((i, j), acc); @@ -453,16 +453,16 @@ macro_rules! mat_mul_mat_impl( ) macro_rules! vec_mul_mat_impl( - ($t: ident, $v: ident, $trhs: ident, $dim: expr, $zero: expr) => ( - impl $trhs> for $t { + ($t: ident, $v: ident, $dim: expr, $zero: expr) => ( + impl Mul<$t, $v> for $v { #[inline] - fn binop(left: &$v, right: &$t) -> $v { + fn mul(&self, right: &$t) -> $v { let mut res : $v = $zero(); for i in range(0u, $dim) { for j in range(0u, $dim) { unsafe { - let val = res.at_fast(i) + left.at_fast(j) * right.at_fast((j, i)); + let val = res.at_fast(i) + self.at_fast(j) * right.at_fast((j, i)); res.set_fast(i, val) } } @@ -475,16 +475,16 @@ macro_rules! vec_mul_mat_impl( ) macro_rules! mat_mul_vec_impl( - ($t: ident, $v: ident, $trhs: ident, $dim: expr, $zero: expr) => ( - impl $trhs> for $v { + ($t: ident, $v: ident, $dim: expr, $zero: expr) => ( + impl Mul<$v, $v> for $t { #[inline] - fn binop(left: &$t, right: &$v) -> $v { + fn mul(&self, right: &$v) -> $v { let mut res : $v = $zero(); for i in range(0u, $dim) { for j in range(0u, $dim) { unsafe { - let val = res.at_fast(i) + left.at_fast((i, j)) * right.at_fast(j); + let val = res.at_fast(i) + self.at_fast((i, j)) * right.at_fast(j); res.set_fast(i, val) } } @@ -497,14 +497,14 @@ macro_rules! mat_mul_vec_impl( ) macro_rules! pnt_mul_mat_impl( - ($t: ident, $v: ident, $trhs: ident, $dim: expr, $zero: expr) => ( - vec_mul_mat_impl!($t, $v, $trhs, $dim, $zero) + ($t: ident, $v: ident, $dim: expr, $zero: expr) => ( + vec_mul_mat_impl!($t, $v, $dim, $zero) ) ) macro_rules! mat_mul_pnt_impl( - ($t: ident, $v: ident, $trhs: ident, $dim: expr, $zero: expr) => ( - mat_mul_vec_impl!($t, $v, $trhs, $dim, $zero) + ($t: ident, $v: ident, $dim: expr, $zero: expr) => ( + mat_mul_vec_impl!($t, $v, $dim, $zero) ) ) diff --git a/src/structs/metal.rs b/src/structs/metal.rs deleted file mode 100644 index 5e69c8c3..00000000 --- a/src/structs/metal.rs +++ /dev/null @@ -1,88 +0,0 @@ -#![macro_escape] - -#![doc(hidden)] // we hide doc to not have to document the $trhs double dispatch trait. - -// Create the traits needed to do fancy operator oveloading. -// This is a meta version of -// http://smallcultfollowing.com/babysteps/blog/2012/10/04/refining-traits-slash-impls/ -// -// Hopefully future version of the language will make this useless. -macro_rules! double_dispatch_binop_decl_trait( - ($t: ident, $trhs: ident) => ( - pub trait $trhs { - /// Applies the binary operation represented by this trait. - /// - /// In infix notation, assuming the operation is noted `*`, the following is computed: - /// `right * left`. - fn binop(left: &$t, right: &Self) -> Res; - } - ) -) - -// Macro driving the `Mul` trait to use the related trait for double redispatch. -macro_rules! mul_redispatch_impl( - ($t: ident, $trhs: ident) => ( - impl, Res> Mul for $t { - #[inline(always)] - fn mul(&self, other: &Rhs) -> Res { - $trhs::binop(self, other) - } - } - ) -) - -// Macro driving the `Div` trait to use the related trait for double redispatch. -macro_rules! div_redispatch_impl( - ($t: ident, $trhs: ident) => ( - impl, Res> Div for $t { - #[inline(always)] - fn div(&self, other: &Rhs) -> Res { - $trhs::binop(self, other) - } - } - ) -) - -// Macro driving the `Add` trait to use the related trait for double redispatch. -macro_rules! add_redispatch_impl( - ($t: ident, $trhs: ident) => ( - impl, Res> Add for $t { - #[inline(always)] - fn add(&self, other: &Rhs) -> Res { - $trhs::binop(self, other) - } - } - ) -) - -// Macro driving the `Sub` trait to use the related trait for double redispatch. -macro_rules! sub_redispatch_impl( - ($t: ident, $trhs: ident) => ( - impl, Res> Sub for $t { - #[inline(always)] - fn sub(&self, other: &Rhs) -> Res { - $trhs::binop(self, other) - } - } - ) -) - -// Double dispatch traits to drive the Cast method for structured types with one type parameter. -macro_rules! double_dispatch_cast_decl_trait( - ($t: ident, $tcast: ident) => ( - pub trait $tcast { - fn to(Self) -> $t; - } - ) -) - -macro_rules! cast_redispatch_impl( - ($t:ident, $tcast: ident) => ( - impl, N> Cast for $t { - #[inline(always)] - fn from(t: T) -> $t { - $tcast::to(t) - } - } - ) -) diff --git a/src/structs/mod.rs b/src/structs/mod.rs index 88fe3fbd..c9409a8f 100644 --- a/src/structs/mod.rs +++ b/src/structs/mod.rs @@ -11,20 +11,6 @@ pub use self::persp::{Persp3, PerspMat3}; pub use self::ortho::{Ortho3, OrthoMat3}; pub use self::quat::{Quat, UnitQuat}; -pub use self::vec::{Vec1MulRhs, Vec2MulRhs, Vec3MulRhs, Vec4MulRhs, Vec5MulRhs, Vec6MulRhs, - Vec1DivRhs, Vec2DivRhs, Vec3DivRhs, Vec4DivRhs, Vec5DivRhs, Vec6DivRhs, - Vec1AddRhs, Vec2AddRhs, Vec3AddRhs, Vec4AddRhs, Vec5AddRhs, Vec6AddRhs, - Vec1SubRhs, Vec2SubRhs, Vec3SubRhs, Vec4SubRhs, Vec5SubRhs, Vec6SubRhs}; -pub use self::pnt::{Pnt1MulRhs, Pnt2MulRhs, Pnt3MulRhs, Pnt4MulRhs, Pnt5MulRhs, Pnt6MulRhs, - Pnt1DivRhs, Pnt2DivRhs, Pnt3DivRhs, Pnt4DivRhs, Pnt5DivRhs, Pnt6DivRhs, - Pnt1AddRhs, Pnt2AddRhs, Pnt3AddRhs, Pnt4AddRhs, Pnt5AddRhs, Pnt6AddRhs, - Pnt1SubRhs, Pnt2SubRhs, Pnt3SubRhs, Pnt4SubRhs, Pnt5SubRhs, Pnt6SubRhs}; -pub use self::mat::{Mat1MulRhs, Mat2MulRhs, Mat3MulRhs, Mat4MulRhs, Mat5MulRhs, Mat6MulRhs, - Mat1DivRhs, Mat2DivRhs, Mat3DivRhs, Mat4DivRhs, Mat5DivRhs, Mat6DivRhs, - Mat1AddRhs, Mat2AddRhs, Mat3AddRhs, Mat4AddRhs, Mat5AddRhs, Mat6AddRhs, - Mat1SubRhs, Mat2SubRhs, Mat3SubRhs, Mat4SubRhs, Mat5SubRhs, Mat6SubRhs}; - -mod metal; mod dmat; mod dvec_macros; mod dvec; diff --git a/src/structs/pnt.rs b/src/structs/pnt.rs index fcd9a718..306c974a 100644 --- a/src/structs/pnt.rs +++ b/src/structs/pnt.rs @@ -38,20 +38,14 @@ pub struct Pnt1 { pub x: N } -double_dispatch_binop_decl_trait!(Pnt1, Pnt1MulRhs) -double_dispatch_binop_decl_trait!(Pnt1, Pnt1DivRhs) -double_dispatch_binop_decl_trait!(Pnt1, Pnt1AddRhs) -double_dispatch_binop_decl_trait!(Pnt1, Pnt1SubRhs) -double_dispatch_cast_decl_trait!(Pnt1, Pnt1Cast) -mul_redispatch_impl!(Pnt1, Pnt1MulRhs) -div_redispatch_impl!(Pnt1, Pnt1DivRhs) -add_redispatch_impl!(Pnt1, Pnt1AddRhs) -sub_redispatch_impl!(Pnt1, Pnt1SubRhs) -cast_redispatch_impl!(Pnt1, Pnt1Cast) new_impl!(Pnt1, x) orig_impl!(Pnt1, x) ord_impl!(Pnt1, x) -vec_cast_impl!(Pnt1, Pnt1Cast, x) +scalar_mul_impl!(Pnt1, x) +scalar_div_impl!(Pnt1, x) +scalar_add_impl!(Pnt1, x) +scalar_sub_impl!(Pnt1, x) +vec_cast_impl!(Pnt1, x) as_array_impl!(Pnt1, 1) index_impl!(Pnt1) indexable_impl!(Pnt1, 1) @@ -60,59 +54,11 @@ new_repeat_impl!(Pnt1, val, x) dim_impl!(Pnt1, 1) container_impl!(Pnt1) pnt_as_vec_impl!(Pnt1, Vec1, x) -pnt_sub_impl!(Pnt1, Vec1, Pnt1SubRhs) +pnt_sub_impl!(Pnt1, Vec1) neg_impl!(Pnt1, x) -pnt_add_vec_impl!(Pnt1, Vec1, Pnt1AddRhs, x) -pnt_sub_vec_impl!(Pnt1, Vec1, Pnt1SubRhs, x) +pnt_add_vec_impl!(Pnt1, Vec1, x) +pnt_sub_vec_impl!(Pnt1, Vec1, x) scalar_ops_impl!(Pnt1, x) -vec_mul_scalar_impl!(Pnt1, f64, Pnt1MulRhs, x) -vec_mul_scalar_impl!(Pnt1, f32, Pnt1MulRhs, x) -vec_mul_scalar_impl!(Pnt1, u64, Pnt1MulRhs, x) -vec_mul_scalar_impl!(Pnt1, u32, Pnt1MulRhs, x) -vec_mul_scalar_impl!(Pnt1, u16, Pnt1MulRhs, x) -vec_mul_scalar_impl!(Pnt1, u8, Pnt1MulRhs, x) -vec_mul_scalar_impl!(Pnt1, i64, Pnt1MulRhs, x) -vec_mul_scalar_impl!(Pnt1, i32, Pnt1MulRhs, x) -vec_mul_scalar_impl!(Pnt1, i16, Pnt1MulRhs, x) -vec_mul_scalar_impl!(Pnt1, i8, Pnt1MulRhs, x) -vec_mul_scalar_impl!(Pnt1, uint, Pnt1MulRhs, x) -vec_mul_scalar_impl!(Pnt1, int, Pnt1MulRhs, x) -vec_div_scalar_impl!(Pnt1, f64, Pnt1DivRhs, x) -vec_div_scalar_impl!(Pnt1, f32, Pnt1DivRhs, x) -vec_div_scalar_impl!(Pnt1, u64, Pnt1DivRhs, x) -vec_div_scalar_impl!(Pnt1, u32, Pnt1DivRhs, x) -vec_div_scalar_impl!(Pnt1, u16, Pnt1DivRhs, x) -vec_div_scalar_impl!(Pnt1, u8, Pnt1DivRhs, x) -vec_div_scalar_impl!(Pnt1, i64, Pnt1DivRhs, x) -vec_div_scalar_impl!(Pnt1, i32, Pnt1DivRhs, x) -vec_div_scalar_impl!(Pnt1, i16, Pnt1DivRhs, x) -vec_div_scalar_impl!(Pnt1, i8, Pnt1DivRhs, x) -vec_div_scalar_impl!(Pnt1, uint, Pnt1DivRhs, x) -vec_div_scalar_impl!(Pnt1, int, Pnt1DivRhs, x) -vec_add_scalar_impl!(Pnt1, f64, Pnt1AddRhs, x) -vec_add_scalar_impl!(Pnt1, f32, Pnt1AddRhs, x) -vec_add_scalar_impl!(Pnt1, u64, Pnt1AddRhs, x) -vec_add_scalar_impl!(Pnt1, u32, Pnt1AddRhs, x) -vec_add_scalar_impl!(Pnt1, u16, Pnt1AddRhs, x) -vec_add_scalar_impl!(Pnt1, u8, Pnt1AddRhs, x) -vec_add_scalar_impl!(Pnt1, i64, Pnt1AddRhs, x) -vec_add_scalar_impl!(Pnt1, i32, Pnt1AddRhs, x) -vec_add_scalar_impl!(Pnt1, i16, Pnt1AddRhs, x) -vec_add_scalar_impl!(Pnt1, i8, Pnt1AddRhs, x) -vec_add_scalar_impl!(Pnt1, uint, Pnt1AddRhs, x) -vec_add_scalar_impl!(Pnt1, int, Pnt1AddRhs, x) -vec_sub_scalar_impl!(Pnt1, f64, Pnt1SubRhs, x) -vec_sub_scalar_impl!(Pnt1, f32, Pnt1SubRhs, x) -vec_sub_scalar_impl!(Pnt1, u64, Pnt1SubRhs, x) -vec_sub_scalar_impl!(Pnt1, u32, Pnt1SubRhs, x) -vec_sub_scalar_impl!(Pnt1, u16, Pnt1SubRhs, x) -vec_sub_scalar_impl!(Pnt1, u8, Pnt1SubRhs, x) -vec_sub_scalar_impl!(Pnt1, i64, Pnt1SubRhs, x) -vec_sub_scalar_impl!(Pnt1, i32, Pnt1SubRhs, x) -vec_sub_scalar_impl!(Pnt1, i16, Pnt1SubRhs, x) -vec_sub_scalar_impl!(Pnt1, i8, Pnt1SubRhs, x) -vec_sub_scalar_impl!(Pnt1, uint, Pnt1SubRhs, x) -vec_sub_scalar_impl!(Pnt1, int, Pnt1SubRhs, x) approx_eq_impl!(Pnt1, x) from_iterator_impl!(Pnt1, iterator) bounded_impl!(Pnt1, x) @@ -121,7 +67,7 @@ iterable_impl!(Pnt1, 1) iterable_mut_impl!(Pnt1, 1) pnt_to_homogeneous_impl!(Pnt1, Pnt2, y, x) pnt_from_homogeneous_impl!(Pnt1, Pnt2, y, x) -num_float_pnt_impl!(Pnt1, Vec1, Pnt1MulRhs, Pnt1DivRhs) +num_float_pnt_impl!(Pnt1, Vec1) /// Point of dimension 2. #[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)] @@ -132,20 +78,14 @@ pub struct Pnt2 { pub y: N } -double_dispatch_binop_decl_trait!(Pnt2, Pnt2MulRhs) -double_dispatch_binop_decl_trait!(Pnt2, Pnt2DivRhs) -double_dispatch_binop_decl_trait!(Pnt2, Pnt2AddRhs) -double_dispatch_binop_decl_trait!(Pnt2, Pnt2SubRhs) -double_dispatch_cast_decl_trait!(Pnt2, Pnt2Cast) -mul_redispatch_impl!(Pnt2, Pnt2MulRhs) -div_redispatch_impl!(Pnt2, Pnt2DivRhs) -add_redispatch_impl!(Pnt2, Pnt2AddRhs) -sub_redispatch_impl!(Pnt2, Pnt2SubRhs) -cast_redispatch_impl!(Pnt2, Pnt2Cast) new_impl!(Pnt2, x, y) orig_impl!(Pnt2, x, y) ord_impl!(Pnt2, x, y) -vec_cast_impl!(Pnt2, Pnt2Cast, x, y) +scalar_mul_impl!(Pnt2, x, y) +scalar_div_impl!(Pnt2, x, y) +scalar_add_impl!(Pnt2, x, y) +scalar_sub_impl!(Pnt2, x, y) +vec_cast_impl!(Pnt2, x, y) as_array_impl!(Pnt2, 2) index_impl!(Pnt2) indexable_impl!(Pnt2, 2) @@ -154,59 +94,11 @@ new_repeat_impl!(Pnt2, val, x, y) dim_impl!(Pnt2, 2) container_impl!(Pnt2) pnt_as_vec_impl!(Pnt2, Vec2, x, y) -pnt_sub_impl!(Pnt2, Vec2, Pnt2SubRhs) +pnt_sub_impl!(Pnt2, Vec2) neg_impl!(Pnt2, x, y) -pnt_add_vec_impl!(Pnt2, Vec2, Pnt2AddRhs, x, y) -pnt_sub_vec_impl!(Pnt2, Vec2, Pnt2SubRhs, x, y) +pnt_add_vec_impl!(Pnt2, Vec2, x, y) +pnt_sub_vec_impl!(Pnt2, Vec2, x, y) scalar_ops_impl!(Pnt2, x, y) -vec_mul_scalar_impl!(Pnt2, f64, Pnt2MulRhs, x, y) -vec_mul_scalar_impl!(Pnt2, f32, Pnt2MulRhs, x, y) -vec_mul_scalar_impl!(Pnt2, u64, Pnt2MulRhs, x, y) -vec_mul_scalar_impl!(Pnt2, u32, Pnt2MulRhs, x, y) -vec_mul_scalar_impl!(Pnt2, u16, Pnt2MulRhs, x, y) -vec_mul_scalar_impl!(Pnt2, u8, Pnt2MulRhs, x, y) -vec_mul_scalar_impl!(Pnt2, i64, Pnt2MulRhs, x, y) -vec_mul_scalar_impl!(Pnt2, i32, Pnt2MulRhs, x, y) -vec_mul_scalar_impl!(Pnt2, i16, Pnt2MulRhs, x, y) -vec_mul_scalar_impl!(Pnt2, i8, Pnt2MulRhs, x, y) -vec_mul_scalar_impl!(Pnt2, uint, Pnt2MulRhs, x, y) -vec_mul_scalar_impl!(Pnt2, int, Pnt2MulRhs, x, y) -vec_div_scalar_impl!(Pnt2, f64, Pnt2DivRhs, x, y) -vec_div_scalar_impl!(Pnt2, f32, Pnt2DivRhs, x, y) -vec_div_scalar_impl!(Pnt2, u64, Pnt2DivRhs, x, y) -vec_div_scalar_impl!(Pnt2, u32, Pnt2DivRhs, x, y) -vec_div_scalar_impl!(Pnt2, u16, Pnt2DivRhs, x, y) -vec_div_scalar_impl!(Pnt2, u8, Pnt2DivRhs, x, y) -vec_div_scalar_impl!(Pnt2, i64, Pnt2DivRhs, x, y) -vec_div_scalar_impl!(Pnt2, i32, Pnt2DivRhs, x, y) -vec_div_scalar_impl!(Pnt2, i16, Pnt2DivRhs, x, y) -vec_div_scalar_impl!(Pnt2, i8, Pnt2DivRhs, x, y) -vec_div_scalar_impl!(Pnt2, uint, Pnt2DivRhs, x, y) -vec_div_scalar_impl!(Pnt2, int, Pnt2DivRhs, x, y) -vec_add_scalar_impl!(Pnt2, f64, Pnt2AddRhs, x, y) -vec_add_scalar_impl!(Pnt2, f32, Pnt2AddRhs, x, y) -vec_add_scalar_impl!(Pnt2, u64, Pnt2AddRhs, x, y) -vec_add_scalar_impl!(Pnt2, u32, Pnt2AddRhs, x, y) -vec_add_scalar_impl!(Pnt2, u16, Pnt2AddRhs, x, y) -vec_add_scalar_impl!(Pnt2, u8, Pnt2AddRhs, x, y) -vec_add_scalar_impl!(Pnt2, i64, Pnt2AddRhs, x, y) -vec_add_scalar_impl!(Pnt2, i32, Pnt2AddRhs, x, y) -vec_add_scalar_impl!(Pnt2, i16, Pnt2AddRhs, x, y) -vec_add_scalar_impl!(Pnt2, i8, Pnt2AddRhs, x, y) -vec_add_scalar_impl!(Pnt2, uint, Pnt2AddRhs, x, y) -vec_add_scalar_impl!(Pnt2, int, Pnt2AddRhs, x, y) -vec_sub_scalar_impl!(Pnt2, f64, Pnt2SubRhs, x, y) -vec_sub_scalar_impl!(Pnt2, f32, Pnt2SubRhs, x, y) -vec_sub_scalar_impl!(Pnt2, u64, Pnt2SubRhs, x, y) -vec_sub_scalar_impl!(Pnt2, u32, Pnt2SubRhs, x, y) -vec_sub_scalar_impl!(Pnt2, u16, Pnt2SubRhs, x, y) -vec_sub_scalar_impl!(Pnt2, u8, Pnt2SubRhs, x, y) -vec_sub_scalar_impl!(Pnt2, i64, Pnt2SubRhs, x, y) -vec_sub_scalar_impl!(Pnt2, i32, Pnt2SubRhs, x, y) -vec_sub_scalar_impl!(Pnt2, i16, Pnt2SubRhs, x, y) -vec_sub_scalar_impl!(Pnt2, i8, Pnt2SubRhs, x, y) -vec_sub_scalar_impl!(Pnt2, uint, Pnt2SubRhs, x, y) -vec_sub_scalar_impl!(Pnt2, int, Pnt2SubRhs, x, y) approx_eq_impl!(Pnt2, x, y) from_iterator_impl!(Pnt2, iterator, iterator) bounded_impl!(Pnt2, x, y) @@ -215,7 +107,7 @@ iterable_impl!(Pnt2, 2) iterable_mut_impl!(Pnt2, 2) pnt_to_homogeneous_impl!(Pnt2, Pnt3, z, x, y) pnt_from_homogeneous_impl!(Pnt2, Pnt3, z, x, y) -num_float_pnt_impl!(Pnt2, Vec2, Pnt2MulRhs, Pnt2DivRhs) +num_float_pnt_impl!(Pnt2, Vec2) /// Point of dimension 3. #[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)] @@ -228,20 +120,14 @@ pub struct Pnt3 { pub z: N } -double_dispatch_binop_decl_trait!(Pnt3, Pnt3MulRhs) -double_dispatch_binop_decl_trait!(Pnt3, Pnt3DivRhs) -double_dispatch_binop_decl_trait!(Pnt3, Pnt3AddRhs) -double_dispatch_binop_decl_trait!(Pnt3, Pnt3SubRhs) -double_dispatch_cast_decl_trait!(Pnt3, Pnt3Cast) -mul_redispatch_impl!(Pnt3, Pnt3MulRhs) -div_redispatch_impl!(Pnt3, Pnt3DivRhs) -add_redispatch_impl!(Pnt3, Pnt3AddRhs) -sub_redispatch_impl!(Pnt3, Pnt3SubRhs) -cast_redispatch_impl!(Pnt3, Pnt3Cast) new_impl!(Pnt3, x, y, z) orig_impl!(Pnt3, x, y, z) ord_impl!(Pnt3, x, y, z) -vec_cast_impl!(Pnt3, Pnt3Cast, x, y, z) +scalar_mul_impl!(Pnt3, x, y, z) +scalar_div_impl!(Pnt3, x, y, z) +scalar_add_impl!(Pnt3, x, y, z) +scalar_sub_impl!(Pnt3, x, y, z) +vec_cast_impl!(Pnt3, x, y, z) as_array_impl!(Pnt3, 3) index_impl!(Pnt3) indexable_impl!(Pnt3, 3) @@ -250,59 +136,11 @@ new_repeat_impl!(Pnt3, val, x, y, z) dim_impl!(Pnt3, 3) container_impl!(Pnt3) pnt_as_vec_impl!(Pnt3, Vec3, x, y, z) -pnt_sub_impl!(Pnt3, Vec3, Pnt3SubRhs) +pnt_sub_impl!(Pnt3, Vec3) neg_impl!(Pnt3, x, y, z) -pnt_add_vec_impl!(Pnt3, Vec3, Pnt3AddRhs, x, y, z) -pnt_sub_vec_impl!(Pnt3, Vec3, Pnt3SubRhs, x, y, z) +pnt_add_vec_impl!(Pnt3, Vec3, x, y, z) +pnt_sub_vec_impl!(Pnt3, Vec3, x, y, z) scalar_ops_impl!(Pnt3, x, y, z) -vec_mul_scalar_impl!(Pnt3, f64, Pnt3MulRhs, x, y, z) -vec_mul_scalar_impl!(Pnt3, f32, Pnt3MulRhs, x, y, z) -vec_mul_scalar_impl!(Pnt3, u64, Pnt3MulRhs, x, y, z) -vec_mul_scalar_impl!(Pnt3, u32, Pnt3MulRhs, x, y, z) -vec_mul_scalar_impl!(Pnt3, u16, Pnt3MulRhs, x, y, z) -vec_mul_scalar_impl!(Pnt3, u8, Pnt3MulRhs, x, y, z) -vec_mul_scalar_impl!(Pnt3, i64, Pnt3MulRhs, x, y, z) -vec_mul_scalar_impl!(Pnt3, i32, Pnt3MulRhs, x, y, z) -vec_mul_scalar_impl!(Pnt3, i16, Pnt3MulRhs, x, y, z) -vec_mul_scalar_impl!(Pnt3, i8, Pnt3MulRhs, x, y, z) -vec_mul_scalar_impl!(Pnt3, uint, Pnt3MulRhs, x, y, z) -vec_mul_scalar_impl!(Pnt3, int, Pnt3MulRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, f64, Pnt3DivRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, f32, Pnt3DivRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, u64, Pnt3DivRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, u32, Pnt3DivRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, u16, Pnt3DivRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, u8, Pnt3DivRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, i64, Pnt3DivRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, i32, Pnt3DivRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, i16, Pnt3DivRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, i8, Pnt3DivRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, uint, Pnt3DivRhs, x, y, z) -vec_div_scalar_impl!(Pnt3, int, Pnt3DivRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, f64, Pnt3AddRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, f32, Pnt3AddRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, u64, Pnt3AddRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, u32, Pnt3AddRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, u16, Pnt3AddRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, u8, Pnt3AddRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, i64, Pnt3AddRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, i32, Pnt3AddRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, i16, Pnt3AddRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, i8, Pnt3AddRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, uint, Pnt3AddRhs, x, y, z) -vec_add_scalar_impl!(Pnt3, int, Pnt3AddRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, f64, Pnt3SubRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, f32, Pnt3SubRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, u64, Pnt3SubRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, u32, Pnt3SubRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, u16, Pnt3SubRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, u8, Pnt3SubRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, i64, Pnt3SubRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, i32, Pnt3SubRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, i16, Pnt3SubRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, i8, Pnt3SubRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, uint, Pnt3SubRhs, x, y, z) -vec_sub_scalar_impl!(Pnt3, int, Pnt3SubRhs, x, y, z) approx_eq_impl!(Pnt3, x, y, z) from_iterator_impl!(Pnt3, iterator, iterator, iterator) bounded_impl!(Pnt3, x, y, z) @@ -311,7 +149,7 @@ iterable_impl!(Pnt3, 3) iterable_mut_impl!(Pnt3, 3) pnt_to_homogeneous_impl!(Pnt3, Pnt4, w, x, y, z) pnt_from_homogeneous_impl!(Pnt3, Pnt4, w, x, y, z) -num_float_pnt_impl!(Pnt3, Vec3, Pnt3MulRhs, Pnt3DivRhs) +num_float_pnt_impl!(Pnt3, Vec3) /// Point of dimension 4. #[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)] @@ -326,20 +164,14 @@ pub struct Pnt4 { pub w: N } -double_dispatch_binop_decl_trait!(Pnt4, Pnt4MulRhs) -double_dispatch_binop_decl_trait!(Pnt4, Pnt4DivRhs) -double_dispatch_binop_decl_trait!(Pnt4, Pnt4AddRhs) -double_dispatch_binop_decl_trait!(Pnt4, Pnt4SubRhs) -double_dispatch_cast_decl_trait!(Pnt4, Pnt4Cast) -mul_redispatch_impl!(Pnt4, Pnt4MulRhs) -div_redispatch_impl!(Pnt4, Pnt4DivRhs) -add_redispatch_impl!(Pnt4, Pnt4AddRhs) -sub_redispatch_impl!(Pnt4, Pnt4SubRhs) -cast_redispatch_impl!(Pnt4, Pnt4Cast) new_impl!(Pnt4, x, y, z, w) orig_impl!(Pnt4, x, y, z, w) ord_impl!(Pnt4, x, y, z, w) -vec_cast_impl!(Pnt4, Pnt4Cast, x, y, z, w) +scalar_mul_impl!(Pnt4, x, y, z, w) +scalar_div_impl!(Pnt4, x, y, z, w) +scalar_add_impl!(Pnt4, x, y, z, w) +scalar_sub_impl!(Pnt4, x, y, z, w) +vec_cast_impl!(Pnt4, x, y, z, w) as_array_impl!(Pnt4, 4) index_impl!(Pnt4) indexable_impl!(Pnt4, 4) @@ -348,59 +180,11 @@ new_repeat_impl!(Pnt4, val, x, y, z, w) dim_impl!(Pnt4, 4) container_impl!(Pnt4) pnt_as_vec_impl!(Pnt4, Vec4, x, y, z, w) -pnt_sub_impl!(Pnt4, Vec4, Pnt4SubRhs) +pnt_sub_impl!(Pnt4, Vec4) neg_impl!(Pnt4, x, y, z, w) -pnt_add_vec_impl!(Pnt4, Vec4, Pnt4AddRhs, x, y, z, w) -pnt_sub_vec_impl!(Pnt4, Vec4, Pnt4SubRhs, x, y, z, w) +pnt_add_vec_impl!(Pnt4, Vec4, x, y, z, w) +pnt_sub_vec_impl!(Pnt4, Vec4, x, y, z, w) scalar_ops_impl!(Pnt4, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, f64, Pnt4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, f32, Pnt4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, u64, Pnt4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, u32, Pnt4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, u16, Pnt4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, u8, Pnt4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, i64, Pnt4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, i32, Pnt4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, i16, Pnt4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, i8, Pnt4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, uint, Pnt4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Pnt4, int, Pnt4MulRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, f64, Pnt4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, f32, Pnt4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, u64, Pnt4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, u32, Pnt4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, u16, Pnt4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, u8, Pnt4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, i64, Pnt4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, i32, Pnt4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, i16, Pnt4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, i8, Pnt4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, uint, Pnt4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Pnt4, int, Pnt4DivRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, f64, Pnt4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, f32, Pnt4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, u64, Pnt4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, u32, Pnt4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, u16, Pnt4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, u8, Pnt4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, i64, Pnt4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, i32, Pnt4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, i16, Pnt4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, i8, Pnt4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, uint, Pnt4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Pnt4, int, Pnt4AddRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, f64, Pnt4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, f32, Pnt4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, u64, Pnt4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, u32, Pnt4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, u16, Pnt4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, u8, Pnt4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, i64, Pnt4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, i32, Pnt4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, i16, Pnt4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, i8, Pnt4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, uint, Pnt4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Pnt4, int, Pnt4SubRhs, x, y, z, w) approx_eq_impl!(Pnt4, x, y, z, w) from_iterator_impl!(Pnt4, iterator, iterator, iterator, iterator) bounded_impl!(Pnt4, x, y, z, w) @@ -409,7 +193,7 @@ iterable_impl!(Pnt4, 4) iterable_mut_impl!(Pnt4, 4) pnt_to_homogeneous_impl!(Pnt4, Pnt5, a, x, y, z, w) pnt_from_homogeneous_impl!(Pnt4, Pnt5, a, x, y, z, w) -num_float_pnt_impl!(Pnt4, Vec4, Pnt4MulRhs, Pnt4DivRhs) +num_float_pnt_impl!(Pnt4, Vec4) /// Point of dimension 5. #[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)] @@ -426,20 +210,14 @@ pub struct Pnt5 { pub a: N } -double_dispatch_binop_decl_trait!(Pnt5, Pnt5MulRhs) -double_dispatch_binop_decl_trait!(Pnt5, Pnt5DivRhs) -double_dispatch_binop_decl_trait!(Pnt5, Pnt5AddRhs) -double_dispatch_binop_decl_trait!(Pnt5, Pnt5SubRhs) -double_dispatch_cast_decl_trait!(Pnt5, Pnt5Cast) -mul_redispatch_impl!(Pnt5, Pnt5MulRhs) -div_redispatch_impl!(Pnt5, Pnt5DivRhs) -add_redispatch_impl!(Pnt5, Pnt5AddRhs) -sub_redispatch_impl!(Pnt5, Pnt5SubRhs) -cast_redispatch_impl!(Pnt5, Pnt5Cast) new_impl!(Pnt5, x, y, z, w, a) orig_impl!(Pnt5, x, y, z, w, a) ord_impl!(Pnt5, x, y, z, w, a) -vec_cast_impl!(Pnt5, Pnt5Cast, x, y, z, w, a) +scalar_mul_impl!(Pnt5, x, y, z, w, a) +scalar_div_impl!(Pnt5, x, y, z, w, a) +scalar_add_impl!(Pnt5, x, y, z, w, a) +scalar_sub_impl!(Pnt5, x, y, z, w, a) +vec_cast_impl!(Pnt5, x, y, z, w, a) as_array_impl!(Pnt5, 5) index_impl!(Pnt5) indexable_impl!(Pnt5, 5) @@ -448,59 +226,11 @@ new_repeat_impl!(Pnt5, val, x, y, z, w, a) dim_impl!(Pnt5, 5) container_impl!(Pnt5) pnt_as_vec_impl!(Pnt5, Vec5, x, y, z, w, a) -pnt_sub_impl!(Pnt5, Vec5, Pnt5SubRhs) +pnt_sub_impl!(Pnt5, Vec5) neg_impl!(Pnt5, x, y, z, w, a) -pnt_add_vec_impl!(Pnt5, Vec5, Pnt5AddRhs, x, y, z, w, a) -pnt_sub_vec_impl!(Pnt5, Vec5, Pnt5SubRhs, x, y, z, w, a) +pnt_add_vec_impl!(Pnt5, Vec5, x, y, z, w, a) +pnt_sub_vec_impl!(Pnt5, Vec5, x, y, z, w, a) scalar_ops_impl!(Pnt5, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, f64, Pnt5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, f32, Pnt5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, u64, Pnt5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, u32, Pnt5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, u16, Pnt5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, u8, Pnt5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, i64, Pnt5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, i32, Pnt5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, i16, Pnt5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, i8, Pnt5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, uint, Pnt5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Pnt5, int, Pnt5MulRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, f64, Pnt5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, f32, Pnt5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, u64, Pnt5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, u32, Pnt5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, u16, Pnt5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, u8, Pnt5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, i64, Pnt5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, i32, Pnt5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, i16, Pnt5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, i8, Pnt5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, uint, Pnt5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Pnt5, int, Pnt5DivRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, f64, Pnt5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, f32, Pnt5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, u64, Pnt5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, u32, Pnt5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, u16, Pnt5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, u8, Pnt5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, i64, Pnt5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, i32, Pnt5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, i16, Pnt5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, i8, Pnt5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, uint, Pnt5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Pnt5, int, Pnt5AddRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, f64, Pnt5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, f32, Pnt5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, u64, Pnt5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, u32, Pnt5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, u16, Pnt5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, u8, Pnt5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, i64, Pnt5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, i32, Pnt5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, i16, Pnt5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, i8, Pnt5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, uint, Pnt5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Pnt5, int, Pnt5SubRhs, x, y, z, w, a) approx_eq_impl!(Pnt5, x, y, z, w, a) from_iterator_impl!(Pnt5, iterator, iterator, iterator, iterator, iterator) bounded_impl!(Pnt5, x, y, z, w, a) @@ -509,7 +239,7 @@ iterable_impl!(Pnt5, 5) iterable_mut_impl!(Pnt5, 5) pnt_to_homogeneous_impl!(Pnt5, Pnt6, b, x, y, z, w, a) pnt_from_homogeneous_impl!(Pnt5, Pnt6, b, x, y, z, w, a) -num_float_pnt_impl!(Pnt5, Vec5, Pnt5MulRhs, Pnt5DivRhs) +num_float_pnt_impl!(Pnt5, Vec5) /// Point of dimension 6. #[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)] @@ -528,20 +258,14 @@ pub struct Pnt6 { pub b: N } -double_dispatch_binop_decl_trait!(Pnt6, Pnt6MulRhs) -double_dispatch_binop_decl_trait!(Pnt6, Pnt6DivRhs) -double_dispatch_binop_decl_trait!(Pnt6, Pnt6AddRhs) -double_dispatch_binop_decl_trait!(Pnt6, Pnt6SubRhs) -double_dispatch_cast_decl_trait!(Pnt6, Pnt6Cast) -mul_redispatch_impl!(Pnt6, Pnt6MulRhs) -div_redispatch_impl!(Pnt6, Pnt6DivRhs) -add_redispatch_impl!(Pnt6, Pnt6AddRhs) -sub_redispatch_impl!(Pnt6, Pnt6SubRhs) -cast_redispatch_impl!(Pnt6, Pnt6Cast) new_impl!(Pnt6, x, y, z, w, a, b) orig_impl!(Pnt6, x, y, z, w, a, b) ord_impl!(Pnt6, x, y, z, w, a, b) -vec_cast_impl!(Pnt6, Pnt6Cast, x, y, z, w, a, b) +scalar_mul_impl!(Pnt6, x, y, z, w, a, b) +scalar_div_impl!(Pnt6, x, y, z, w, a, b) +scalar_add_impl!(Pnt6, x, y, z, w, a, b) +scalar_sub_impl!(Pnt6, x, y, z, w, a, b) +vec_cast_impl!(Pnt6, x, y, z, w, a, b) as_array_impl!(Pnt6, 6) index_impl!(Pnt6) indexable_impl!(Pnt6, 6) @@ -550,63 +274,15 @@ new_repeat_impl!(Pnt6, val, x, y, z, w, a, b) dim_impl!(Pnt6, 6) container_impl!(Pnt6) pnt_as_vec_impl!(Pnt6, Vec6, x, y, z, w, a, b) -pnt_sub_impl!(Pnt6, Vec6, Pnt6SubRhs) +pnt_sub_impl!(Pnt6, Vec6) neg_impl!(Pnt6, x, y, z, w, a, b) -pnt_add_vec_impl!(Pnt6, Vec6, Pnt6AddRhs, x, y, z, w, a, b) -pnt_sub_vec_impl!(Pnt6, Vec6, Pnt6SubRhs, x, y, z, w, a, b) +pnt_add_vec_impl!(Pnt6, Vec6, x, y, z, w, a, b) +pnt_sub_vec_impl!(Pnt6, Vec6, x, y, z, w, a, b) scalar_ops_impl!(Pnt6, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, f64, Pnt6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, f32, Pnt6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, u64, Pnt6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, u32, Pnt6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, u16, Pnt6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, u8, Pnt6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, i64, Pnt6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, i32, Pnt6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, i16, Pnt6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, i8, Pnt6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, uint, Pnt6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Pnt6, int, Pnt6MulRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, f64, Pnt6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, f32, Pnt6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, u64, Pnt6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, u32, Pnt6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, u16, Pnt6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, u8, Pnt6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, i64, Pnt6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, i32, Pnt6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, i16, Pnt6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, i8, Pnt6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, uint, Pnt6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Pnt6, int, Pnt6DivRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, f64, Pnt6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, f32, Pnt6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, u64, Pnt6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, u32, Pnt6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, u16, Pnt6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, u8, Pnt6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, i64, Pnt6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, i32, Pnt6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, i16, Pnt6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, i8, Pnt6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, uint, Pnt6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Pnt6, int, Pnt6AddRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, f64, Pnt6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, f32, Pnt6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, u64, Pnt6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, u32, Pnt6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, u16, Pnt6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, u8, Pnt6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, i64, Pnt6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, i32, Pnt6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, i16, Pnt6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, i8, Pnt6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, uint, Pnt6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Pnt6, int, Pnt6SubRhs, x, y, z, w, a, b) approx_eq_impl!(Pnt6, x, y, z, w, a, b) from_iterator_impl!(Pnt6, iterator, iterator, iterator, iterator, iterator, iterator) bounded_impl!(Pnt6, x, y, z, w, a, b) axpy_impl!(Pnt6, x, y, z, w, a, b) iterable_impl!(Pnt6, 6) iterable_mut_impl!(Pnt6, 6) -num_float_pnt_impl!(Pnt6, Vec6, Pnt6MulRhs, Pnt6DivRhs) +num_float_pnt_impl!(Pnt6, Vec6) diff --git a/src/structs/pnt_macros.rs b/src/structs/pnt_macros.rs index 83e2c320..909851ba 100644 --- a/src/structs/pnt_macros.rs +++ b/src/structs/pnt_macros.rs @@ -20,33 +20,33 @@ macro_rules! orig_impl( ) macro_rules! pnt_sub_impl( - ($t: ident, $tv: ident, $trhs: ident) => ( - impl> $trhs> for $t { + ($t: ident, $tv: ident) => ( + impl> Sub<$t, $tv> for $t { #[inline] - fn binop(left: &$t, right: &$t) -> $tv { - *left.as_vec() - *right.as_vec() + fn sub(&self, right: &$t) -> $tv { + *self.as_vec() - *right.as_vec() } } ) ) macro_rules! pnt_add_vec_impl( - ($t: ident, $tv: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $tv { + ($t: ident, $tv: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Add<$tv, $t> for $t { #[inline] - fn binop(left: &$t, right: &$tv) -> $t { - $t::new(left.$comp0 + right.$comp0 $(, left.$compN + right.$compN)*) + fn add(&self, right: &$tv) -> $t { + $t::new(self.$comp0 + right.$comp0 $(, self.$compN + right.$compN)*) } } ) ) macro_rules! pnt_sub_vec_impl( - ($t: ident, $tv: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $tv { + ($t: ident, $tv: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Sub<$tv, $t> for $t { #[inline] - fn binop(left: &$t, right: &$tv) -> $t { - $t::new(left.$comp0 - right.$comp0 $(, left.$compN - right.$compN)*) + fn sub(&self, right: &$tv) -> $t { + $t::new(self.$comp0 - right.$comp0 $(, self.$compN - right.$compN)*) } } ) @@ -130,13 +130,13 @@ macro_rules! pnt_from_homogeneous_impl( ) macro_rules! num_float_pnt_impl( - ($t: ident, $tv: ident $(,$trhs: ident)*) => ( + ($t: ident, $tv: ident) => ( impl NumPnt> for $t - where N: BaseNum + Zero $(+ $trhs>)* { + where N: BaseNum { } impl FloatPnt> for $t - where N: BaseNum + One + Zero + ApproxEq + BaseFloat $(+ $trhs>)* { + where N: BaseFloat + ApproxEq { } ) ) diff --git a/src/structs/quat.rs b/src/structs/quat.rs index 163485ef..f90d7c99 100644 --- a/src/structs/quat.rs +++ b/src/structs/quat.rs @@ -6,7 +6,7 @@ use std::mem; use std::num; use std::rand::{Rand, Rng}; use std::slice::{Items, MutItems}; -use structs::{Vec3, Pnt3, Rot3, Mat3, Vec3MulRhs, Pnt3MulRhs}; +use structs::{Vec3, Pnt3, Rot3, Mat3}; use traits::operations::{ApproxEq, Inv, POrd, POrdering, Axpy, ScalarAdd, ScalarSub, ScalarMul, ScalarDiv}; use traits::structure::{Cast, Indexable, Iterable, IterableMut, Dim, Shape, BaseFloat, BaseNum, Zero, @@ -121,21 +121,21 @@ impl Norm for Quat { } } -impl + Sub + Add> QuatMulRhs> for Quat { +impl + Sub + Add> Mul, Quat> for Quat { #[inline] - fn binop(left: &Quat, right: &Quat) -> Quat { + fn mul(&self, right: &Quat) -> Quat { Quat::new( - left.w * right.w - left.i * right.i - left.j * right.j - left.k * right.k, - left.w * right.i + left.i * right.w + left.j * right.k - left.k * right.j, - left.w * right.j - left.i * right.k + left.j * right.w + left.k * right.i, - left.w * right.k + left.i * right.j - left.j * right.i + left.k * right.w) + self.w * right.w - self.i * right.i - self.j * right.j - self.k * right.k, + self.w * right.i + self.i * right.w + self.j * right.k - self.k * right.j, + self.w * right.j - self.i * right.k + self.j * right.w + self.k * right.i, + self.w * right.k + self.i * right.j - self.j * right.i + self.k * right.w) } } -impl + BaseFloat + Clone> QuatDivRhs> for Quat { +impl + BaseFloat + Clone> Div, Quat> for Quat { #[inline] - fn binop(left: &Quat, right: &Quat) -> Quat { - *left * Inv::inv_cpy(right).expect("Unable to invert the denominator.") + fn div(&self, right: &Quat) -> Quat { + *self * Inv::inv_cpy(right).expect("Unable to invert the denominator.") } } @@ -307,49 +307,49 @@ impl + Clone> Div, UnitQuat> for UnitQ } } -impl UnitQuatMulRhs> for UnitQuat { +impl Mul, UnitQuat> for UnitQuat { #[inline] - fn binop(left: &UnitQuat, right: &UnitQuat) -> UnitQuat { - UnitQuat { q: left.q * right.q } + fn mul(&self, right: &UnitQuat) -> UnitQuat { + UnitQuat { q: self.q * right.q } } } -impl UnitQuatMulRhs> for Vec3 { +impl Mul, Vec3> for UnitQuat { #[inline] - fn binop(left: &UnitQuat, right: &Vec3) -> Vec3 { + fn mul(&self, right: &Vec3) -> Vec3 { let _2: N = ::one::() + ::one(); - let mut t = Cross::cross(left.q.vector(), right); + let mut t = Cross::cross(self.q.vector(), right); t.x = t.x * _2; t.y = t.y * _2; t.z = t.z * _2; - Vec3::new(t.x * left.q.w, t.y * left.q.w, t.z * left.q.w) + - Cross::cross(left.q.vector(), &t) + + Vec3::new(t.x * self.q.w, t.y * self.q.w, t.z * self.q.w) + + Cross::cross(self.q.vector(), &t) + *right } } -impl UnitQuatMulRhs> for Pnt3 { +impl Mul, Pnt3> for UnitQuat { #[inline] - fn binop(left: &UnitQuat, right: &Pnt3) -> Pnt3 { - ::orig::>() + *left * *right.as_vec() + fn mul(&self, right: &Pnt3) -> Pnt3 { + ::orig::>() + *self * *right.as_vec() } } -impl Vec3MulRhs> for UnitQuat { +impl Mul, Vec3> for Vec3 { #[inline] - fn binop(left: &Vec3, right: &UnitQuat) -> Vec3 { + fn mul(&self, right: &UnitQuat) -> Vec3 { let mut inv_quat = right.clone(); inv_quat.inv(); - inv_quat * *left + inv_quat * *self } } -impl Pnt3MulRhs> for UnitQuat { +impl Mul, Pnt3> for Pnt3 { #[inline] - fn binop(left: &Pnt3, right: &UnitQuat) -> Pnt3 { - ::orig::>() + *left.as_vec() * *right + fn mul(&self, right: &UnitQuat) -> Pnt3 { + ::orig::>() + *self.as_vec() * *right } } @@ -447,19 +447,9 @@ impl Transform> for UnitQuat { } } -double_dispatch_binop_decl_trait!(Quat, QuatMulRhs) -double_dispatch_binop_decl_trait!(Quat, QuatDivRhs) -double_dispatch_binop_decl_trait!(Quat, QuatAddRhs) -double_dispatch_binop_decl_trait!(Quat, QuatSubRhs) -double_dispatch_cast_decl_trait!(Quat, QuatCast) -mul_redispatch_impl!(Quat, QuatMulRhs) -div_redispatch_impl!(Quat, QuatDivRhs) -add_redispatch_impl!(Quat, QuatAddRhs) -sub_redispatch_impl!(Quat, QuatSubRhs) -cast_redispatch_impl!(Quat, QuatCast) ord_impl!(Quat, w, i, j, k) vec_axis_impl!(Quat, w, i, j, k) -vec_cast_impl!(Quat, QuatCast, w, i, j, k) +vec_cast_impl!(Quat, w, i, j, k) as_array_impl!(Quat, 4) index_impl!(Quat) indexable_impl!(Quat, 4) @@ -467,58 +457,14 @@ at_fast_impl!(Quat, 4) new_repeat_impl!(Quat, val, w, i, j, k) dim_impl!(Quat, 3) container_impl!(Quat) -add_impl!(Quat, QuatAddRhs, w, i, j, k) -sub_impl!(Quat, QuatSubRhs, w, i, j, k) +add_impl!(Quat, w, i, j, k) +sub_impl!(Quat, w, i, j, k) +scalar_add_impl!(Quat, w, i, j, k) +scalar_sub_impl!(Quat, w, i, j, k) +scalar_mul_impl!(Quat, w, i, j, k) +scalar_div_impl!(Quat, w, i, j, k) neg_impl!(Quat, w, i, j, k) scalar_ops_impl!(Quat, w, i, j, k) -vec_mul_scalar_impl!(Quat, f64, QuatMulRhs, w, i, j, k) -vec_mul_scalar_impl!(Quat, f32, QuatMulRhs, w, i, j, k) -vec_mul_scalar_impl!(Quat, u64, QuatMulRhs, w, i, j, k) -vec_mul_scalar_impl!(Quat, u32, QuatMulRhs, w, i, j, k) -vec_mul_scalar_impl!(Quat, u16, QuatMulRhs, w, i, j, k) -vec_mul_scalar_impl!(Quat, u8, QuatMulRhs, w, i, j, k) -vec_mul_scalar_impl!(Quat, i64, QuatMulRhs, w, i, j, k) -vec_mul_scalar_impl!(Quat, i32, QuatMulRhs, w, i, j, k) -vec_mul_scalar_impl!(Quat, i16, QuatMulRhs, w, i, j, k) -vec_mul_scalar_impl!(Quat, i8, QuatMulRhs, w, i, j, k) -vec_mul_scalar_impl!(Quat, uint, QuatMulRhs, w, i, j, k) -vec_mul_scalar_impl!(Quat, int, QuatMulRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, f64, QuatDivRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, f32, QuatDivRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, u64, QuatDivRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, u32, QuatDivRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, u16, QuatDivRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, u8, QuatDivRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, i64, QuatDivRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, i32, QuatDivRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, i16, QuatDivRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, i8, QuatDivRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, uint, QuatDivRhs, w, i, j, k) -vec_div_scalar_impl!(Quat, int, QuatDivRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, f64, QuatAddRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, f32, QuatAddRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, u64, QuatAddRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, u32, QuatAddRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, u16, QuatAddRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, u8, QuatAddRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, i64, QuatAddRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, i32, QuatAddRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, i16, QuatAddRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, i8, QuatAddRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, uint, QuatAddRhs, w, i, j, k) -vec_add_scalar_impl!(Quat, int, QuatAddRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, f64, QuatSubRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, f32, QuatSubRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, u64, QuatSubRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, u32, QuatSubRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, u16, QuatSubRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, u8, QuatSubRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, i64, QuatSubRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, i32, QuatSubRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, i16, QuatSubRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, i8, QuatSubRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, uint, QuatSubRhs, w, i, j, k) -vec_sub_scalar_impl!(Quat, int, QuatSubRhs, w, i, j, k) zero_one_impl!(Quat, w, i, j, k) approx_eq_impl!(Quat, w, i, j, k) from_iterator_impl!(Quat, iterator, iterator, iterator, iterator) @@ -527,6 +473,4 @@ axpy_impl!(Quat, w, i, j, k) iterable_impl!(Quat, 4) iterable_mut_impl!(Quat, 4) -double_dispatch_binop_decl_trait!(UnitQuat, UnitQuatMulRhs) -mul_redispatch_impl!(UnitQuat, UnitQuatMulRhs) dim_impl!(UnitQuat, 3) diff --git a/src/structs/rot.rs b/src/structs/rot.rs index a5a69b48..a09d0889 100644 --- a/src/structs/rot.rs +++ b/src/structs/rot.rs @@ -7,8 +7,8 @@ use traits::geometry::{Rotate, Rotation, AbsoluteRotate, RotationMatrix, Transfo Norm, Cross}; use traits::structure::{Cast, Dim, Row, Col, BaseFloat, BaseNum, Zero, One}; use traits::operations::{Absolute, Inv, Transpose, ApproxEq}; -use structs::vec::{Vec1, Vec2, Vec3, Vec4, Vec2MulRhs, Vec3MulRhs, Vec4MulRhs}; -use structs::pnt::{Pnt2, Pnt3, Pnt4, Pnt2MulRhs, Pnt3MulRhs, Pnt4MulRhs}; +use structs::vec::{Vec1, Vec2, Vec3, Vec4}; +use structs::pnt::{Pnt2, Pnt3, Pnt4}; use structs::mat::{Mat2, Mat3, Mat4, Mat5}; @@ -376,17 +376,15 @@ Rotation> for Rot4 { * Common implementations. */ -double_dispatch_binop_decl_trait!(Rot2, Rot2MulRhs) -mul_redispatch_impl!(Rot2, Rot2MulRhs) submat_impl!(Rot2, Mat2) -rotate_impl!(Rot2RotateRhs, Rot2, Vec2, Pnt2) -transform_impl!(Rot2TransformRhs, Rot2, Vec2, Pnt2) +rotate_impl!(Rot2, Vec2, Pnt2) +transform_impl!(Rot2, Vec2, Pnt2) dim_impl!(Rot2, 2) -rot_mul_rot_impl!(Rot2, Rot2MulRhs) -rot_mul_vec_impl!(Rot2, Vec2, Rot2MulRhs) -vec_mul_rot_impl!(Rot2, Vec2, Vec2MulRhs) -rot_mul_pnt_impl!(Rot2, Pnt2, Rot2MulRhs) -pnt_mul_rot_impl!(Rot2, Pnt2, Pnt2MulRhs) +rot_mul_rot_impl!(Rot2) +rot_mul_vec_impl!(Rot2, Vec2) +vec_mul_rot_impl!(Rot2, Vec2) +rot_mul_pnt_impl!(Rot2, Pnt2) +pnt_mul_rot_impl!(Rot2, Pnt2) one_impl!(Rot2) rotation_matrix_impl!(Rot2, Vec2, Vec1) col_impl!(Rot2, Vec2) @@ -398,17 +396,15 @@ inv_impl!(Rot2) transpose_impl!(Rot2) approx_eq_impl!(Rot2) -double_dispatch_binop_decl_trait!(Rot3, Rot3MulRhs) -mul_redispatch_impl!(Rot3, Rot3MulRhs) submat_impl!(Rot3, Mat3) -rotate_impl!(Rot3RotateRhs, Rot3, Vec3, Pnt3) -transform_impl!(Rot3TransformRhs, Rot3, Vec3, Pnt3) +rotate_impl!(Rot3, Vec3, Pnt3) +transform_impl!(Rot3, Vec3, Pnt3) dim_impl!(Rot3, 3) -rot_mul_rot_impl!(Rot3, Rot3MulRhs) -rot_mul_vec_impl!(Rot3, Vec3, Rot3MulRhs) -vec_mul_rot_impl!(Rot3, Vec3, Vec3MulRhs) -rot_mul_pnt_impl!(Rot3, Pnt3, Rot3MulRhs) -pnt_mul_rot_impl!(Rot3, Pnt3, Pnt3MulRhs) +rot_mul_rot_impl!(Rot3) +rot_mul_vec_impl!(Rot3, Vec3) +vec_mul_rot_impl!(Rot3, Vec3) +rot_mul_pnt_impl!(Rot3, Pnt3) +pnt_mul_rot_impl!(Rot3, Pnt3) one_impl!(Rot3) rotation_matrix_impl!(Rot3, Vec3, Vec3) col_impl!(Rot3, Vec3) @@ -420,17 +416,15 @@ inv_impl!(Rot3) transpose_impl!(Rot3) approx_eq_impl!(Rot3) -double_dispatch_binop_decl_trait!(Rot4, Rot4MulRhs) -mul_redispatch_impl!(Rot4, Rot4MulRhs) submat_impl!(Rot4, Mat4) -rotate_impl!(Rot4RotateRhs, Rot4, Vec4, Pnt4) -transform_impl!(Rot4TransformRhs, Rot4, Vec4, Pnt4) +rotate_impl!(Rot4, Vec4, Pnt4) +transform_impl!(Rot4, Vec4, Pnt4) dim_impl!(Rot4, 4) -rot_mul_rot_impl!(Rot4, Rot4MulRhs) -rot_mul_vec_impl!(Rot4, Vec4, Rot4MulRhs) -vec_mul_rot_impl!(Rot4, Vec4, Vec4MulRhs) -rot_mul_pnt_impl!(Rot4, Pnt4, Rot4MulRhs) -pnt_mul_rot_impl!(Rot4, Pnt4, Pnt4MulRhs) +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) rotation_matrix_impl!(Rot4, Vec4, Vec4) col_impl!(Rot4, Vec4) diff --git a/src/structs/rot_macros.rs b/src/structs/rot_macros.rs index fbee6c14..51c8b2f1 100644 --- a/src/structs/rot_macros.rs +++ b/src/structs/rot_macros.rs @@ -12,98 +12,56 @@ macro_rules! submat_impl( ) macro_rules! rotate_impl( - ($trhs: ident, $t: ident, $tv: ident, $tp: ident) => ( - /* - * FIXME: we use the double dispatch trick here so that we can rotate vectors _and_ - * points. Remove this as soon as rust supports multidispatch. - */ - pub trait $trhs { - fn rotate(left: &$t, right: &Self) -> Self; - fn inv_rotate(left: &$t, right: &Self) -> Self; - } - - impl> Rotate for $t { - #[inline(always)] - fn rotate(&self, other: &V) -> V { - $trhs::rotate(self, other) + ($t: ident, $tv: ident, $tp: ident) => ( + impl Rotate<$tv> for $t { + #[inline] + fn rotate(&self, v: &$tv) -> $tv { + *self * *v } - #[inline(always)] - fn inv_rotate(&self, other: &V) -> V { - $trhs::inv_rotate(self, other) + #[inline] + fn inv_rotate(&self, v: &$tv) -> $tv { + *v * *self } } - impl $trhs for $tv { + impl Rotate<$tp> for $t { #[inline] - fn rotate(t: &$t, v: &$tv) -> $tv { - *t * *v + fn rotate(&self, p: &$tp) -> $tp { + *self * *p } #[inline] - fn inv_rotate(t: &$t, v: &$tv) -> $tv { - *v * *t - } - } - - impl $trhs for $tp { - #[inline] - fn rotate(t: &$t, p: &$tp) -> $tp { - *t * *p - } - - #[inline] - fn inv_rotate(t: &$t, p: &$tp) -> $tp { - *p * *t + fn inv_rotate(&self, p: &$tp) -> $tp { + *p * *self } } ) ) macro_rules! transform_impl( - ($trhs: ident, $t: ident, $tv: ident, $tp: ident) => ( - /* - * FIXME: we use the double dispatch trick here so that we can transform vectors _and_ - * points. Remove this as soon as rust supports multidispatch. - */ - pub trait $trhs { - fn transform(left: &$t, right: &Self) -> Self; - fn inv_transform(left: &$t, right: &Self) -> Self; - } - - impl> Transform for $t { - #[inline(always)] - fn transform(&self, other: &V) -> V { - $trhs::transform(self, other) + ($t: ident, $tv: ident, $tp: ident) => ( + impl Transform<$tv> for $t { + #[inline] + fn transform(&self, v: &$tv) -> $tv { + self.rotate(v) } - #[inline(always)] - fn inv_transform(&self, other: &V) -> V { - $trhs::inv_transform(self, other) + #[inline] + fn inv_transform(&self, v: &$tv) -> $tv { + self.inv_rotate(v) } } - impl $trhs for $tv { + impl Transform<$tp> for $t { #[inline] - fn transform(t: &$t, v: &$tv) -> $tv { - t.rotate(v) + fn transform(&self, p: &$tp) -> $tp { + self.rotate(p) } #[inline] - fn inv_transform(t: &$t, v: &$tv) -> $tv { - t.inv_rotate(v) - } - } - - impl $trhs for $tp { - #[inline] - fn transform(t: &$t, p: &$tp) -> $tp { - t.rotate(p) - } - - #[inline] - fn inv_transform(t: &$t, p: &$tp) -> $tp { - t.inv_rotate(p) + fn inv_transform(&self, p: &$tp) -> $tp { + self.inv_rotate(p) } } ) @@ -143,47 +101,47 @@ macro_rules! one_impl( ) macro_rules! rot_mul_rot_impl( - ($t: ident, $mulrhs: ident) => ( - impl $mulrhs> for $t { + ($t: ident) => ( + impl Mul<$t, $t> for $t { #[inline] - fn binop(left: &$t, right: &$t) -> $t { - $t { submat: left.submat * right.submat } + fn mul(&self, right: &$t) -> $t { + $t { submat: self.submat * right.submat } } } ) ) macro_rules! rot_mul_vec_impl( - ($t: ident, $tv: ident, $mulrhs: ident) => ( - impl $mulrhs> for $tv { + ($t: ident, $tv: ident) => ( + impl Mul<$tv, $tv> for $t { #[inline] - fn binop(left: &$t, right: &$tv) -> $tv { - left.submat * *right + fn mul(&self, right: &$tv) -> $tv { + self.submat * *right } } ) ) macro_rules! rot_mul_pnt_impl( - ($t: ident, $tv: ident, $mulrhs: ident) => ( - rot_mul_vec_impl!($t, $tv, $mulrhs) + ($t: ident, $tv: ident) => ( + rot_mul_vec_impl!($t, $tv) ) ) macro_rules! vec_mul_rot_impl( - ($t: ident, $tv: ident, $mulrhs: ident) => ( - impl $mulrhs> for $t { + ($t: ident, $tv: ident) => ( + impl Mul<$t, $tv> for $tv { #[inline] - fn binop(left: &$tv, right: &$t) -> $tv { - *left * right.submat + fn mul(&self, right: &$t) -> $tv { + *self * right.submat } } ) ) macro_rules! pnt_mul_rot_impl( - ($t: ident, $tv: ident, $mulrhs: ident) => ( - vec_mul_rot_impl!($t, $tv, $mulrhs) + ($t: ident, $tv: ident) => ( + vec_mul_rot_impl!($t, $tv) ) ) diff --git a/src/structs/spec/mat.rs b/src/structs/spec/mat.rs index c41b6f44..7e585994 100644 --- a/src/structs/spec/mat.rs +++ b/src/structs/spec/mat.rs @@ -1,6 +1,6 @@ -use structs::vec::{Vec2, Vec3, Vec2MulRhs, Vec3MulRhs}; -use structs::pnt::{Pnt2, Pnt3, Pnt2MulRhs, Pnt3MulRhs}; -use structs::mat::{Mat1, Mat2, Mat3, Mat3MulRhs, Mat2MulRhs}; +use structs::vec::{Vec2, Vec3}; +use structs::pnt::{Pnt2, Pnt3}; +use structs::mat::{Mat1, Mat2, Mat3}; use traits::operations::{Inv, Det, ApproxEq}; use traits::structure::{Row, Col, BaseNum}; @@ -211,118 +211,118 @@ impl Col> for Mat3 { } } -impl + Add> Mat3MulRhs> for Mat3 { +impl + Add> Mul, Mat3> for Mat3 { #[inline] - fn binop(left: &Mat3, right: &Mat3) -> Mat3 { + fn mul(&self, right: &Mat3) -> Mat3 { Mat3::new( - left.m11 * right.m11 + left.m12 * right.m21 + left.m13 * right.m31, - left.m11 * right.m12 + left.m12 * right.m22 + left.m13 * right.m32, - left.m11 * right.m13 + left.m12 * right.m23 + left.m13 * right.m33, + self.m11 * right.m11 + self.m12 * right.m21 + self.m13 * right.m31, + self.m11 * right.m12 + self.m12 * right.m22 + self.m13 * right.m32, + self.m11 * right.m13 + self.m12 * right.m23 + self.m13 * right.m33, - left.m21 * right.m11 + left.m22 * right.m21 + left.m23 * right.m31, - left.m21 * right.m12 + left.m22 * right.m22 + left.m23 * right.m32, - left.m21 * right.m13 + left.m22 * right.m23 + left.m23 * right.m33, + self.m21 * right.m11 + self.m22 * right.m21 + self.m23 * right.m31, + self.m21 * right.m12 + self.m22 * right.m22 + self.m23 * right.m32, + self.m21 * right.m13 + self.m22 * right.m23 + self.m23 * right.m33, - left.m31 * right.m11 + left.m32 * right.m21 + left.m33 * right.m31, - left.m31 * right.m12 + left.m32 * right.m22 + left.m33 * right.m32, - left.m31 * right.m13 + left.m32 * right.m23 + left.m33 * right.m33 + self.m31 * right.m11 + self.m32 * right.m21 + self.m33 * right.m31, + self.m31 * right.m12 + self.m32 * right.m22 + self.m33 * right.m32, + self.m31 * right.m13 + self.m32 * right.m23 + self.m33 * right.m33 ) } } -impl + Add> Mat2MulRhs> for Mat2 { +impl + Add> Mul, Mat2> for Mat2 { #[inline(always)] - fn binop(left: &Mat2, right: &Mat2) -> Mat2 { + fn mul(&self, right: &Mat2) -> Mat2 { Mat2::new( - left.m11 * right.m11 + left.m12 * right.m21, - left.m11 * right.m12 + left.m12 * right.m22, + self.m11 * right.m11 + self.m12 * right.m21, + self.m11 * right.m12 + self.m12 * right.m22, - left.m21 * right.m11 + left.m22 * right.m21, - left.m21 * right.m12 + left.m22 * right.m22 + self.m21 * right.m11 + self.m22 * right.m21, + self.m21 * right.m12 + self.m22 * right.m22 ) } } -impl + Add> Mat3MulRhs> for Vec3 { +impl + Add> Mul, Vec3> for Mat3 { #[inline(always)] - fn binop(left: &Mat3, right: &Vec3) -> Vec3 { + fn mul(&self, right: &Vec3) -> Vec3 { Vec3::new( - left.m11 * right.x + left.m12 * right.y + left.m13 * right.z, - left.m21 * right.x + left.m22 * right.y + left.m23 * right.z, - left.m31 * right.x + left.m32 * right.y + left.m33 * right.z + self.m11 * right.x + self.m12 * right.y + self.m13 * right.z, + self.m21 * right.x + self.m22 * right.y + self.m23 * right.z, + self.m31 * right.x + self.m32 * right.y + self.m33 * right.z ) } } -impl + Add> Vec3MulRhs> for Mat3 { +impl + Add> Mul, Vec3> for Vec3 { #[inline(always)] - fn binop(left: &Vec3, right: &Mat3) -> Vec3 { + fn mul(&self, right: &Mat3) -> Vec3 { Vec3::new( - left.x * right.m11 + left.y * right.m21 + left.z * right.m31, - left.x * right.m12 + left.y * right.m22 + left.z * right.m32, - left.x * right.m13 + left.y * right.m23 + left.z * right.m33 + self.x * right.m11 + self.y * right.m21 + self.z * right.m31, + self.x * right.m12 + self.y * right.m22 + self.z * right.m32, + self.x * right.m13 + self.y * right.m23 + self.z * right.m33 ) } } -impl + Add> Vec2MulRhs> for Mat2 { +impl + Add> Mul, Vec2> for Vec2 { #[inline(always)] - fn binop(left: &Vec2, right: &Mat2) -> Vec2 { + fn mul(&self, right: &Mat2) -> Vec2 { Vec2::new( - left.x * right.m11 + left.y * right.m21, - left.x * right.m12 + left.y * right.m22 + self.x * right.m11 + self.y * right.m21, + self.x * right.m12 + self.y * right.m22 ) } } -impl + Add> Mat2MulRhs> for Vec2 { +impl + Add> Mul, Vec2> for Mat2 { #[inline(always)] - fn binop(left: &Mat2, right: &Vec2) -> Vec2 { + fn mul(&self, right: &Vec2) -> Vec2 { Vec2::new( - left.m11 * right.x + left.m12 * right.y, - left.m21 * right.x + left.m22 * right.y + self.m11 * right.x + self.m12 * right.y, + self.m21 * right.x + self.m22 * right.y ) } } -impl + Add> Mat3MulRhs> for Pnt3 { +impl + Add> Mul, Pnt3> for Mat3 { #[inline(always)] - fn binop(left: &Mat3, right: &Pnt3) -> Pnt3 { + fn mul(&self, right: &Pnt3) -> Pnt3 { Pnt3::new( - left.m11 * right.x + left.m12 * right.y + left.m13 * right.z, - left.m21 * right.x + left.m22 * right.y + left.m23 * right.z, - left.m31 * right.x + left.m32 * right.y + left.m33 * right.z + self.m11 * right.x + self.m12 * right.y + self.m13 * right.z, + self.m21 * right.x + self.m22 * right.y + self.m23 * right.z, + self.m31 * right.x + self.m32 * right.y + self.m33 * right.z ) } } -impl + Add> Pnt3MulRhs> for Mat3 { +impl + Add> Mul, Pnt3> for Pnt3 { #[inline(always)] - fn binop(left: &Pnt3, right: &Mat3) -> Pnt3 { + fn mul(&self, right: &Mat3) -> Pnt3 { Pnt3::new( - left.x * right.m11 + left.y * right.m21 + left.z * right.m31, - left.x * right.m12 + left.y * right.m22 + left.z * right.m32, - left.x * right.m13 + left.y * right.m23 + left.z * right.m33 + self.x * right.m11 + self.y * right.m21 + self.z * right.m31, + self.x * right.m12 + self.y * right.m22 + self.z * right.m32, + self.x * right.m13 + self.y * right.m23 + self.z * right.m33 ) } } -impl + Add> Pnt2MulRhs> for Mat2 { +impl + Add> Mul, Pnt2> for Pnt2 { #[inline(always)] - fn binop(left: &Pnt2, right: &Mat2) -> Pnt2 { + fn mul(&self, right: &Mat2) -> Pnt2 { Pnt2::new( - left.x * right.m11 + left.y * right.m21, - left.x * right.m12 + left.y * right.m22 + self.x * right.m11 + self.y * right.m21, + self.x * right.m12 + self.y * right.m22 ) } } -impl + Add> Mat2MulRhs> for Pnt2 { +impl + Add> Mul, Pnt2> for Mat2 { #[inline(always)] - fn binop(left: &Mat2, right: &Pnt2) -> Pnt2 { + fn mul(&self, right: &Pnt2) -> Pnt2 { Pnt2::new( - left.m11 * right.x + left.m12 * right.y, - left.m21 * right.x + left.m22 * right.y + self.m11 * right.x + self.m12 * right.y, + self.m21 * right.x + self.m22 * right.y ) } } diff --git a/src/structs/vec.rs b/src/structs/vec.rs index fa9fefda..904c8857 100644 --- a/src/structs/vec.rs +++ b/src/structs/vec.rs @@ -33,26 +33,16 @@ impl Vec0 { } /// Vector of dimension 1. -#[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] +#[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Show)] pub struct Vec1 { /// First component of the vector. pub x: N } -double_dispatch_binop_decl_trait!(Vec1, Vec1MulRhs) -double_dispatch_binop_decl_trait!(Vec1, Vec1DivRhs) -double_dispatch_binop_decl_trait!(Vec1, Vec1AddRhs) -double_dispatch_binop_decl_trait!(Vec1, Vec1SubRhs) -double_dispatch_cast_decl_trait!(Vec1, Vec1Cast) -mul_redispatch_impl!(Vec1, Vec1MulRhs) -div_redispatch_impl!(Vec1, Vec1DivRhs) -add_redispatch_impl!(Vec1, Vec1AddRhs) -sub_redispatch_impl!(Vec1, Vec1SubRhs) -cast_redispatch_impl!(Vec1, Vec1Cast) new_impl!(Vec1, x) ord_impl!(Vec1, x) vec_axis_impl!(Vec1, x) -vec_cast_impl!(Vec1, Vec1Cast, x) +vec_cast_impl!(Vec1, x) as_array_impl!(Vec1, 1) index_impl!(Vec1) indexable_impl!(Vec1, 1) @@ -61,61 +51,17 @@ new_repeat_impl!(Vec1, val, x) dim_impl!(Vec1, 1) container_impl!(Vec1) // (specialized) basis_impl!(Vec1, 1) -add_impl!(Vec1, Vec1AddRhs, x) -sub_impl!(Vec1, Vec1SubRhs, x) -mul_impl!(Vec1, Vec1MulRhs, x) -div_impl!(Vec1, Vec1DivRhs, x) +add_impl!(Vec1, x) +sub_impl!(Vec1, x) +mul_impl!(Vec1, x) +div_impl!(Vec1, x) +scalar_add_impl!(Vec1, x) +scalar_sub_impl!(Vec1, x) +scalar_mul_impl!(Vec1, x) +scalar_div_impl!(Vec1, x) neg_impl!(Vec1, x) dot_impl!(Vec1, x) scalar_ops_impl!(Vec1, x) -vec_mul_scalar_impl!(Vec1, f64, Vec1MulRhs, x) -vec_mul_scalar_impl!(Vec1, f32, Vec1MulRhs, x) -vec_mul_scalar_impl!(Vec1, u64, Vec1MulRhs, x) -vec_mul_scalar_impl!(Vec1, u32, Vec1MulRhs, x) -vec_mul_scalar_impl!(Vec1, u16, Vec1MulRhs, x) -vec_mul_scalar_impl!(Vec1, u8, Vec1MulRhs, x) -vec_mul_scalar_impl!(Vec1, i64, Vec1MulRhs, x) -vec_mul_scalar_impl!(Vec1, i32, Vec1MulRhs, x) -vec_mul_scalar_impl!(Vec1, i16, Vec1MulRhs, x) -vec_mul_scalar_impl!(Vec1, i8, Vec1MulRhs, x) -vec_mul_scalar_impl!(Vec1, uint, Vec1MulRhs, x) -vec_mul_scalar_impl!(Vec1, int, Vec1MulRhs, x) -vec_div_scalar_impl!(Vec1, f64, Vec1DivRhs, x) -vec_div_scalar_impl!(Vec1, f32, Vec1DivRhs, x) -vec_div_scalar_impl!(Vec1, u64, Vec1DivRhs, x) -vec_div_scalar_impl!(Vec1, u32, Vec1DivRhs, x) -vec_div_scalar_impl!(Vec1, u16, Vec1DivRhs, x) -vec_div_scalar_impl!(Vec1, u8, Vec1DivRhs, x) -vec_div_scalar_impl!(Vec1, i64, Vec1DivRhs, x) -vec_div_scalar_impl!(Vec1, i32, Vec1DivRhs, x) -vec_div_scalar_impl!(Vec1, i16, Vec1DivRhs, x) -vec_div_scalar_impl!(Vec1, i8, Vec1DivRhs, x) -vec_div_scalar_impl!(Vec1, uint, Vec1DivRhs, x) -vec_div_scalar_impl!(Vec1, int, Vec1DivRhs, x) -vec_add_scalar_impl!(Vec1, f64, Vec1AddRhs, x) -vec_add_scalar_impl!(Vec1, f32, Vec1AddRhs, x) -vec_add_scalar_impl!(Vec1, u64, Vec1AddRhs, x) -vec_add_scalar_impl!(Vec1, u32, Vec1AddRhs, x) -vec_add_scalar_impl!(Vec1, u16, Vec1AddRhs, x) -vec_add_scalar_impl!(Vec1, u8, Vec1AddRhs, x) -vec_add_scalar_impl!(Vec1, i64, Vec1AddRhs, x) -vec_add_scalar_impl!(Vec1, i32, Vec1AddRhs, x) -vec_add_scalar_impl!(Vec1, i16, Vec1AddRhs, x) -vec_add_scalar_impl!(Vec1, i8, Vec1AddRhs, x) -vec_add_scalar_impl!(Vec1, uint, Vec1AddRhs, x) -vec_add_scalar_impl!(Vec1, int, Vec1AddRhs, x) -vec_sub_scalar_impl!(Vec1, f64, Vec1SubRhs, x) -vec_sub_scalar_impl!(Vec1, f32, Vec1SubRhs, x) -vec_sub_scalar_impl!(Vec1, u64, Vec1SubRhs, x) -vec_sub_scalar_impl!(Vec1, u32, Vec1SubRhs, x) -vec_sub_scalar_impl!(Vec1, u16, Vec1SubRhs, x) -vec_sub_scalar_impl!(Vec1, u8, Vec1SubRhs, x) -vec_sub_scalar_impl!(Vec1, i64, Vec1SubRhs, x) -vec_sub_scalar_impl!(Vec1, i32, Vec1SubRhs, x) -vec_sub_scalar_impl!(Vec1, i16, Vec1SubRhs, x) -vec_sub_scalar_impl!(Vec1, i8, Vec1SubRhs, x) -vec_sub_scalar_impl!(Vec1, uint, Vec1SubRhs, x) -vec_sub_scalar_impl!(Vec1, int, Vec1SubRhs, x) translation_impl!(Vec1) norm_impl!(Vec1, x) approx_eq_impl!(Vec1, x) @@ -132,7 +78,7 @@ rotate_impl!(Vec1) rotate_impl!(Pnt1) transform_impl!(Vec1, Pnt1) vec_as_pnt_impl!(Vec1, Pnt1, x) -num_float_vec_impl!(Vec1, Vec1MulRhs, Vec1DivRhs) +num_float_vec_impl!(Vec1) absolute_vec_impl!(Vec1, x) /// Vector of dimension 2. @@ -144,20 +90,10 @@ pub struct Vec2 { pub y: N } -double_dispatch_binop_decl_trait!(Vec2, Vec2MulRhs) -double_dispatch_binop_decl_trait!(Vec2, Vec2DivRhs) -double_dispatch_binop_decl_trait!(Vec2, Vec2AddRhs) -double_dispatch_binop_decl_trait!(Vec2, Vec2SubRhs) -double_dispatch_cast_decl_trait!(Vec2, Vec2Cast) -mul_redispatch_impl!(Vec2, Vec2MulRhs) -div_redispatch_impl!(Vec2, Vec2DivRhs) -add_redispatch_impl!(Vec2, Vec2AddRhs) -sub_redispatch_impl!(Vec2, Vec2SubRhs) -cast_redispatch_impl!(Vec2, Vec2Cast) new_impl!(Vec2, x, y) ord_impl!(Vec2, x, y) vec_axis_impl!(Vec2, x, y) -vec_cast_impl!(Vec2, Vec2Cast, x, y) +vec_cast_impl!(Vec2, x, y) as_array_impl!(Vec2, 2) index_impl!(Vec2) indexable_impl!(Vec2, 2) @@ -166,61 +102,17 @@ new_repeat_impl!(Vec2, val, x, y) dim_impl!(Vec2, 2) container_impl!(Vec2) // (specialized) basis_impl!(Vec2, 1) -add_impl!(Vec2, Vec2AddRhs, x, y) -sub_impl!(Vec2, Vec2SubRhs, x, y) -mul_impl!(Vec2, Vec2MulRhs, x, y) -div_impl!(Vec2, Vec2DivRhs, x, y) +add_impl!(Vec2, x, y) +sub_impl!(Vec2, x, y) +mul_impl!(Vec2, x, y) +div_impl!(Vec2, x, y) +scalar_add_impl!(Vec2, x, y) +scalar_sub_impl!(Vec2, x, y) +scalar_mul_impl!(Vec2, x, y) +scalar_div_impl!(Vec2, x, y) neg_impl!(Vec2, x, y) dot_impl!(Vec2, x, y) scalar_ops_impl!(Vec2, x, y) -vec_mul_scalar_impl!(Vec2, f64, Vec2MulRhs, x, y) -vec_mul_scalar_impl!(Vec2, f32, Vec2MulRhs, x, y) -vec_mul_scalar_impl!(Vec2, u64, Vec2MulRhs, x, y) -vec_mul_scalar_impl!(Vec2, u32, Vec2MulRhs, x, y) -vec_mul_scalar_impl!(Vec2, u16, Vec2MulRhs, x, y) -vec_mul_scalar_impl!(Vec2, u8, Vec2MulRhs, x, y) -vec_mul_scalar_impl!(Vec2, i64, Vec2MulRhs, x, y) -vec_mul_scalar_impl!(Vec2, i32, Vec2MulRhs, x, y) -vec_mul_scalar_impl!(Vec2, i16, Vec2MulRhs, x, y) -vec_mul_scalar_impl!(Vec2, i8, Vec2MulRhs, x, y) -vec_mul_scalar_impl!(Vec2, uint, Vec2MulRhs, x, y) -vec_mul_scalar_impl!(Vec2, int, Vec2MulRhs, x, y) -vec_div_scalar_impl!(Vec2, f64, Vec2DivRhs, x, y) -vec_div_scalar_impl!(Vec2, f32, Vec2DivRhs, x, y) -vec_div_scalar_impl!(Vec2, u64, Vec2DivRhs, x, y) -vec_div_scalar_impl!(Vec2, u32, Vec2DivRhs, x, y) -vec_div_scalar_impl!(Vec2, u16, Vec2DivRhs, x, y) -vec_div_scalar_impl!(Vec2, u8, Vec2DivRhs, x, y) -vec_div_scalar_impl!(Vec2, i64, Vec2DivRhs, x, y) -vec_div_scalar_impl!(Vec2, i32, Vec2DivRhs, x, y) -vec_div_scalar_impl!(Vec2, i16, Vec2DivRhs, x, y) -vec_div_scalar_impl!(Vec2, i8, Vec2DivRhs, x, y) -vec_div_scalar_impl!(Vec2, uint, Vec2DivRhs, x, y) -vec_div_scalar_impl!(Vec2, int, Vec2DivRhs, x, y) -vec_add_scalar_impl!(Vec2, f64, Vec2AddRhs, x, y) -vec_add_scalar_impl!(Vec2, f32, Vec2AddRhs, x, y) -vec_add_scalar_impl!(Vec2, u64, Vec2AddRhs, x, y) -vec_add_scalar_impl!(Vec2, u32, Vec2AddRhs, x, y) -vec_add_scalar_impl!(Vec2, u16, Vec2AddRhs, x, y) -vec_add_scalar_impl!(Vec2, u8, Vec2AddRhs, x, y) -vec_add_scalar_impl!(Vec2, i64, Vec2AddRhs, x, y) -vec_add_scalar_impl!(Vec2, i32, Vec2AddRhs, x, y) -vec_add_scalar_impl!(Vec2, i16, Vec2AddRhs, x, y) -vec_add_scalar_impl!(Vec2, i8, Vec2AddRhs, x, y) -vec_add_scalar_impl!(Vec2, uint, Vec2AddRhs, x, y) -vec_add_scalar_impl!(Vec2, int, Vec2AddRhs, x, y) -vec_sub_scalar_impl!(Vec2, f64, Vec2SubRhs, x, y) -vec_sub_scalar_impl!(Vec2, f32, Vec2SubRhs, x, y) -vec_sub_scalar_impl!(Vec2, u64, Vec2SubRhs, x, y) -vec_sub_scalar_impl!(Vec2, u32, Vec2SubRhs, x, y) -vec_sub_scalar_impl!(Vec2, u16, Vec2SubRhs, x, y) -vec_sub_scalar_impl!(Vec2, u8, Vec2SubRhs, x, y) -vec_sub_scalar_impl!(Vec2, i64, Vec2SubRhs, x, y) -vec_sub_scalar_impl!(Vec2, i32, Vec2SubRhs, x, y) -vec_sub_scalar_impl!(Vec2, i16, Vec2SubRhs, x, y) -vec_sub_scalar_impl!(Vec2, i8, Vec2SubRhs, x, y) -vec_sub_scalar_impl!(Vec2, uint, Vec2SubRhs, x, y) -vec_sub_scalar_impl!(Vec2, int, Vec2SubRhs, x, y) translation_impl!(Vec2) norm_impl!(Vec2, x, y) approx_eq_impl!(Vec2, x, y) @@ -237,7 +129,7 @@ rotate_impl!(Vec2) rotate_impl!(Pnt2) transform_impl!(Vec2, Pnt2) vec_as_pnt_impl!(Vec2, Pnt2, x, y) -num_float_vec_impl!(Vec2, Vec2MulRhs, Vec2DivRhs) +num_float_vec_impl!(Vec2) absolute_vec_impl!(Vec2, x, y) /// Vector of dimension 3. @@ -251,20 +143,10 @@ pub struct Vec3 { pub z: N } -double_dispatch_binop_decl_trait!(Vec3, Vec3MulRhs) -double_dispatch_binop_decl_trait!(Vec3, Vec3DivRhs) -double_dispatch_binop_decl_trait!(Vec3, Vec3AddRhs) -double_dispatch_binop_decl_trait!(Vec3, Vec3SubRhs) -double_dispatch_cast_decl_trait!(Vec3, Vec3Cast) -mul_redispatch_impl!(Vec3, Vec3MulRhs) -div_redispatch_impl!(Vec3, Vec3DivRhs) -add_redispatch_impl!(Vec3, Vec3AddRhs) -sub_redispatch_impl!(Vec3, Vec3SubRhs) -cast_redispatch_impl!(Vec3, Vec3Cast) new_impl!(Vec3, x, y, z) ord_impl!(Vec3, x, y, z) vec_axis_impl!(Vec3, x, y, z) -vec_cast_impl!(Vec3, Vec3Cast, x, y, z) +vec_cast_impl!(Vec3, x, y, z) as_array_impl!(Vec3, 3) index_impl!(Vec3) indexable_impl!(Vec3, 3) @@ -273,64 +155,17 @@ new_repeat_impl!(Vec3, val, x, y, z) dim_impl!(Vec3, 3) container_impl!(Vec3) // (specialized) basis_impl!(Vec3, 1) -add_impl!(Vec3, Vec3AddRhs, x, y, z) -sub_impl!(Vec3, Vec3SubRhs, x, y, z) -mul_impl!(Vec3, Vec3MulRhs, x, y, z) -div_impl!(Vec3, Vec3DivRhs, x, y, z) +add_impl!(Vec3, x, y, z) +sub_impl!(Vec3, x, y, z) +mul_impl!(Vec3, x, y, z) +div_impl!(Vec3, x, y, z) +scalar_add_impl!(Vec3, x, y, z) +scalar_sub_impl!(Vec3, x, y, z) +scalar_mul_impl!(Vec3, x, y, z) +scalar_div_impl!(Vec3, x, y, z) neg_impl!(Vec3, x, y, z) dot_impl!(Vec3, x, y, z) scalar_ops_impl!(Vec3, x, y, z) -vec_mul_scalar_impl!(Vec3, f64, Vec3MulRhs, x, y, z) -vec_mul_scalar_impl!(Vec3, f32, Vec3MulRhs, x, y, z) -vec_mul_scalar_impl!(Vec3, u64, Vec3MulRhs, x, y, z) -vec_mul_scalar_impl!(Vec3, u32, Vec3MulRhs, x, y, z) -vec_mul_scalar_impl!(Vec3, u16, Vec3MulRhs, x, y, z) -vec_mul_scalar_impl!(Vec3, u8, Vec3MulRhs, x, y, z) -vec_mul_scalar_impl!(Vec3, i64, Vec3MulRhs, x, y, z) -vec_mul_scalar_impl!(Vec3, i32, Vec3MulRhs, x, y, z) -vec_mul_scalar_impl!(Vec3, i16, Vec3MulRhs, x, y, z) -vec_mul_scalar_impl!(Vec3, i8, Vec3MulRhs, x, y, z) -vec_mul_scalar_impl!(Vec3, uint, Vec3MulRhs, x, y, z) -vec_mul_scalar_impl!(Vec3, int, Vec3MulRhs, x, y, z) - -vec_div_scalar_impl!(Vec3, f64, Vec3DivRhs, x, y, z) -vec_div_scalar_impl!(Vec3, f32, Vec3DivRhs, x, y, z) -vec_div_scalar_impl!(Vec3, u64, Vec3DivRhs, x, y, z) -vec_div_scalar_impl!(Vec3, u32, Vec3DivRhs, x, y, z) -vec_div_scalar_impl!(Vec3, u16, Vec3DivRhs, x, y, z) -vec_div_scalar_impl!(Vec3, u8, Vec3DivRhs, x, y, z) -vec_div_scalar_impl!(Vec3, i64, Vec3DivRhs, x, y, z) -vec_div_scalar_impl!(Vec3, i32, Vec3DivRhs, x, y, z) -vec_div_scalar_impl!(Vec3, i16, Vec3DivRhs, x, y, z) -vec_div_scalar_impl!(Vec3, i8, Vec3DivRhs, x, y, z) -vec_div_scalar_impl!(Vec3, uint, Vec3DivRhs, x, y, z) -vec_div_scalar_impl!(Vec3, int, Vec3DivRhs, x, y, z) - -vec_add_scalar_impl!(Vec3, f64, Vec3AddRhs, x, y, z) -vec_add_scalar_impl!(Vec3, f32, Vec3AddRhs, x, y, z) -vec_add_scalar_impl!(Vec3, u64, Vec3AddRhs, x, y, z) -vec_add_scalar_impl!(Vec3, u32, Vec3AddRhs, x, y, z) -vec_add_scalar_impl!(Vec3, u16, Vec3AddRhs, x, y, z) -vec_add_scalar_impl!(Vec3, u8, Vec3AddRhs, x, y, z) -vec_add_scalar_impl!(Vec3, i64, Vec3AddRhs, x, y, z) -vec_add_scalar_impl!(Vec3, i32, Vec3AddRhs, x, y, z) -vec_add_scalar_impl!(Vec3, i16, Vec3AddRhs, x, y, z) -vec_add_scalar_impl!(Vec3, i8, Vec3AddRhs, x, y, z) -vec_add_scalar_impl!(Vec3, uint, Vec3AddRhs, x, y, z) -vec_add_scalar_impl!(Vec3, int, Vec3AddRhs, x, y, z) - -vec_sub_scalar_impl!(Vec3, f64, Vec3SubRhs, x, y, z) -vec_sub_scalar_impl!(Vec3, f32, Vec3SubRhs, x, y, z) -vec_sub_scalar_impl!(Vec3, u64, Vec3SubRhs, x, y, z) -vec_sub_scalar_impl!(Vec3, u32, Vec3SubRhs, x, y, z) -vec_sub_scalar_impl!(Vec3, u16, Vec3SubRhs, x, y, z) -vec_sub_scalar_impl!(Vec3, u8, Vec3SubRhs, x, y, z) -vec_sub_scalar_impl!(Vec3, i64, Vec3SubRhs, x, y, z) -vec_sub_scalar_impl!(Vec3, i32, Vec3SubRhs, x, y, z) -vec_sub_scalar_impl!(Vec3, i16, Vec3SubRhs, x, y, z) -vec_sub_scalar_impl!(Vec3, i8, Vec3SubRhs, x, y, z) -vec_sub_scalar_impl!(Vec3, uint, Vec3SubRhs, x, y, z) -vec_sub_scalar_impl!(Vec3, int, Vec3SubRhs, x, y, z) translation_impl!(Vec3) norm_impl!(Vec3, x, y ,z) approx_eq_impl!(Vec3, x, y, z) @@ -347,7 +182,7 @@ rotate_impl!(Vec3) rotate_impl!(Pnt3) transform_impl!(Vec3, Pnt3) vec_as_pnt_impl!(Vec3, Pnt3, x, y, z) -num_float_vec_impl!(Vec3, Vec3MulRhs, Vec3DivRhs) +num_float_vec_impl!(Vec3) absolute_vec_impl!(Vec3, x, y, z) @@ -364,20 +199,10 @@ pub struct Vec4 { pub w: N } -double_dispatch_binop_decl_trait!(Vec4, Vec4MulRhs) -double_dispatch_binop_decl_trait!(Vec4, Vec4DivRhs) -double_dispatch_binop_decl_trait!(Vec4, Vec4AddRhs) -double_dispatch_binop_decl_trait!(Vec4, Vec4SubRhs) -double_dispatch_cast_decl_trait!(Vec4, Vec4Cast) -mul_redispatch_impl!(Vec4, Vec4MulRhs) -div_redispatch_impl!(Vec4, Vec4DivRhs) -add_redispatch_impl!(Vec4, Vec4AddRhs) -sub_redispatch_impl!(Vec4, Vec4SubRhs) -cast_redispatch_impl!(Vec4, Vec4Cast) new_impl!(Vec4, x, y, z, w) ord_impl!(Vec4, x, y, z, w) vec_axis_impl!(Vec4, x, y, z, w) -vec_cast_impl!(Vec4, Vec4Cast, x, y, z, w) +vec_cast_impl!(Vec4, x, y, z, w) as_array_impl!(Vec4, 4) index_impl!(Vec4) indexable_impl!(Vec4, 4) @@ -385,62 +210,18 @@ at_fast_impl!(Vec4, 4) new_repeat_impl!(Vec4, val, x, y, z, w) dim_impl!(Vec4, 4) container_impl!(Vec4) -basis_impl!(Vec4, Vec4MulRhs, 4) -add_impl!(Vec4, Vec4AddRhs, x, y, z, w) -sub_impl!(Vec4, Vec4SubRhs, x, y, z, w) -mul_impl!(Vec4, Vec4MulRhs, x, y, z, w) -div_impl!(Vec4, Vec4DivRhs, x, y, z, w) +basis_impl!(Vec4, 4) +add_impl!(Vec4, x, y, z, w) +sub_impl!(Vec4, x, y, z, w) +mul_impl!(Vec4, x, y, z, w) +div_impl!(Vec4, x, y, z, w) +scalar_add_impl!(Vec4, x, y, z, w) +scalar_sub_impl!(Vec4, x, y, z, w) +scalar_mul_impl!(Vec4, x, y, z, w) +scalar_div_impl!(Vec4, x, y, z, w) neg_impl!(Vec4, x, y, z, w) dot_impl!(Vec4, x, y, z, w) scalar_ops_impl!(Vec4, x, y, z, w) -vec_mul_scalar_impl!(Vec4, f64, Vec4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Vec4, f32, Vec4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Vec4, u64, Vec4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Vec4, u32, Vec4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Vec4, u16, Vec4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Vec4, u8, Vec4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Vec4, i64, Vec4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Vec4, i32, Vec4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Vec4, i16, Vec4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Vec4, i8, Vec4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Vec4, uint, Vec4MulRhs, x, y, z, w) -vec_mul_scalar_impl!(Vec4, int, Vec4MulRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, f64, Vec4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, f32, Vec4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, u64, Vec4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, u32, Vec4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, u16, Vec4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, u8, Vec4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, i64, Vec4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, i32, Vec4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, i16, Vec4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, i8, Vec4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, uint, Vec4DivRhs, x, y, z, w) -vec_div_scalar_impl!(Vec4, int, Vec4DivRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, f64, Vec4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, f32, Vec4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, u64, Vec4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, u32, Vec4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, u16, Vec4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, u8, Vec4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, i64, Vec4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, i32, Vec4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, i16, Vec4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, i8, Vec4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, uint, Vec4AddRhs, x, y, z, w) -vec_add_scalar_impl!(Vec4, int, Vec4AddRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, f64, Vec4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, f32, Vec4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, u64, Vec4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, u32, Vec4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, u16, Vec4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, u8, Vec4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, i64, Vec4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, i32, Vec4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, i16, Vec4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, i8, Vec4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, uint, Vec4SubRhs, x, y, z, w) -vec_sub_scalar_impl!(Vec4, int, Vec4SubRhs, x, y, z, w) translation_impl!(Vec4) norm_impl!(Vec4, x, y, z, w) approx_eq_impl!(Vec4, x, y, z, w) @@ -457,7 +238,7 @@ rotate_impl!(Vec4) rotate_impl!(Pnt4) transform_impl!(Vec4, Pnt4) vec_as_pnt_impl!(Vec4, Pnt4, x, y, z, w) -num_float_vec_impl!(Vec4, Vec4MulRhs, Vec4DivRhs) +num_float_vec_impl!(Vec4) absolute_vec_impl!(Vec4, x, y, z, w) /// Vector of dimension 5. @@ -475,20 +256,10 @@ pub struct Vec5 { pub a: N } -double_dispatch_binop_decl_trait!(Vec5, Vec5MulRhs) -double_dispatch_binop_decl_trait!(Vec5, Vec5DivRhs) -double_dispatch_binop_decl_trait!(Vec5, Vec5AddRhs) -double_dispatch_binop_decl_trait!(Vec5, Vec5SubRhs) -double_dispatch_cast_decl_trait!(Vec5, Vec5Cast) -mul_redispatch_impl!(Vec5, Vec5MulRhs) -div_redispatch_impl!(Vec5, Vec5DivRhs) -add_redispatch_impl!(Vec5, Vec5AddRhs) -sub_redispatch_impl!(Vec5, Vec5SubRhs) -cast_redispatch_impl!(Vec5, Vec5Cast) new_impl!(Vec5, x, y, z, w, a) ord_impl!(Vec5, x, y, z, w, a) vec_axis_impl!(Vec5, x, y, z, w, a) -vec_cast_impl!(Vec5, Vec5Cast, x, y, z, w, a) +vec_cast_impl!(Vec5, x, y, z, w, a) as_array_impl!(Vec5, 5) index_impl!(Vec5) indexable_impl!(Vec5, 5) @@ -496,62 +267,18 @@ at_fast_impl!(Vec5, 5) new_repeat_impl!(Vec5, val, x, y, z, w, a) dim_impl!(Vec5, 5) container_impl!(Vec5) -basis_impl!(Vec5, Vec5MulRhs, 5) -add_impl!(Vec5, Vec5AddRhs, x, y, z, w, a) -sub_impl!(Vec5, Vec5SubRhs, x, y, z, w, a) -mul_impl!(Vec5, Vec5MulRhs, x, y, z, w, a) -div_impl!(Vec5, Vec5DivRhs, x, y, z, w, a) +basis_impl!(Vec5, 5) +add_impl!(Vec5, x, y, z, w, a) +sub_impl!(Vec5, x, y, z, w, a) +mul_impl!(Vec5, x, y, z, w, a) +div_impl!(Vec5, x, y, z, w, a) +scalar_add_impl!(Vec5, x, y, z, w, a) +scalar_sub_impl!(Vec5, x, y, z, w, a) +scalar_mul_impl!(Vec5, x, y, z, w, a) +scalar_div_impl!(Vec5, x, y, z, w, a) neg_impl!(Vec5, x, y, z, w, a) dot_impl!(Vec5, x, y, z, w, a) scalar_ops_impl!(Vec5, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, f64, Vec5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, f32, Vec5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, u64, Vec5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, u32, Vec5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, u16, Vec5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, u8, Vec5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, i64, Vec5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, i32, Vec5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, i16, Vec5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, i8, Vec5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, uint, Vec5MulRhs, x, y, z, w, a) -vec_mul_scalar_impl!(Vec5, int, Vec5MulRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, f64, Vec5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, f32, Vec5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, u64, Vec5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, u32, Vec5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, u16, Vec5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, u8, Vec5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, i64, Vec5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, i32, Vec5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, i16, Vec5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, i8, Vec5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, uint, Vec5DivRhs, x, y, z, w, a) -vec_div_scalar_impl!(Vec5, int, Vec5DivRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, f64, Vec5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, f32, Vec5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, u64, Vec5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, u32, Vec5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, u16, Vec5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, u8, Vec5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, i64, Vec5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, i32, Vec5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, i16, Vec5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, i8, Vec5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, uint, Vec5AddRhs, x, y, z, w, a) -vec_add_scalar_impl!(Vec5, int, Vec5AddRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, f64, Vec5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, f32, Vec5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, u64, Vec5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, u32, Vec5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, u16, Vec5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, u8, Vec5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, i64, Vec5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, i32, Vec5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, i16, Vec5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, i8, Vec5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, uint, Vec5SubRhs, x, y, z, w, a) -vec_sub_scalar_impl!(Vec5, int, Vec5SubRhs, x, y, z, w, a) translation_impl!(Vec5) norm_impl!(Vec5, x, y, z, w, a) approx_eq_impl!(Vec5, x, y, z, w, a) @@ -568,7 +295,7 @@ rotate_impl!(Vec5) rotate_impl!(Pnt5) transform_impl!(Vec5, Pnt5) vec_as_pnt_impl!(Vec5, Pnt5, x, y, z, w, a) -num_float_vec_impl!(Vec5, Vec5MulRhs, Vec5DivRhs) +num_float_vec_impl!(Vec5) absolute_vec_impl!(Vec5, x, y, z, w, a) /// Vector of dimension 6. @@ -588,20 +315,10 @@ pub struct Vec6 { pub b: N } -double_dispatch_binop_decl_trait!(Vec6, Vec6MulRhs) -double_dispatch_binop_decl_trait!(Vec6, Vec6DivRhs) -double_dispatch_binop_decl_trait!(Vec6, Vec6AddRhs) -double_dispatch_binop_decl_trait!(Vec6, Vec6SubRhs) -double_dispatch_cast_decl_trait!(Vec6, Vec6Cast) -mul_redispatch_impl!(Vec6, Vec6MulRhs) -div_redispatch_impl!(Vec6, Vec6DivRhs) -add_redispatch_impl!(Vec6, Vec6AddRhs) -sub_redispatch_impl!(Vec6, Vec6SubRhs) -cast_redispatch_impl!(Vec6, Vec6Cast) new_impl!(Vec6, x, y, z, w, a, b) ord_impl!(Vec6, x, y, z, w, a, b) vec_axis_impl!(Vec6, x, y, z, w, a, b) -vec_cast_impl!(Vec6, Vec6Cast, x, y, z, w, a, b) +vec_cast_impl!(Vec6, x, y, z, w, a, b) as_array_impl!(Vec6, 6) index_impl!(Vec6) indexable_impl!(Vec6, 6) @@ -609,62 +326,18 @@ at_fast_impl!(Vec6, 6) new_repeat_impl!(Vec6, val, x, y, z, w, a, b) dim_impl!(Vec6, 6) container_impl!(Vec6) -basis_impl!(Vec6, Vec6MulRhs, 6) -add_impl!(Vec6, Vec6AddRhs, x, y, z, w, a, b) -sub_impl!(Vec6, Vec6SubRhs, x, y, z, w, a, b) -mul_impl!(Vec6, Vec6MulRhs, x, y, z, w, a, b) -div_impl!(Vec6, Vec6DivRhs, x, y, z, w, a, b) +basis_impl!(Vec6, 6) +add_impl!(Vec6, x, y, z, w, a, b) +sub_impl!(Vec6, x, y, z, w, a, b) +mul_impl!(Vec6, x, y, z, w, a, b) +div_impl!(Vec6, x, y, z, w, a, b) +scalar_add_impl!(Vec6, x, y, z, w, a, b) +scalar_sub_impl!(Vec6, x, y, z, w, a, b) +scalar_mul_impl!(Vec6, x, y, z, w, a, b) +scalar_div_impl!(Vec6, x, y, z, w, a, b) neg_impl!(Vec6, x, y, z, w, a, b) dot_impl!(Vec6, x, y, z, w, a, b) scalar_ops_impl!(Vec6, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, f64, Vec6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, f32, Vec6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, u64, Vec6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, u32, Vec6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, u16, Vec6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, u8, Vec6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, i64, Vec6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, i32, Vec6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, i16, Vec6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, i8, Vec6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, uint, Vec6MulRhs, x, y, z, w, a, b) -vec_mul_scalar_impl!(Vec6, int, Vec6MulRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, f64, Vec6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, f32, Vec6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, u64, Vec6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, u32, Vec6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, u16, Vec6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, u8, Vec6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, i64, Vec6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, i32, Vec6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, i16, Vec6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, i8, Vec6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, uint, Vec6DivRhs, x, y, z, w, a, b) -vec_div_scalar_impl!(Vec6, int, Vec6DivRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, f64, Vec6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, f32, Vec6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, u64, Vec6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, u32, Vec6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, u16, Vec6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, u8, Vec6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, i64, Vec6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, i32, Vec6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, i16, Vec6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, i8, Vec6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, uint, Vec6AddRhs, x, y, z, w, a, b) -vec_add_scalar_impl!(Vec6, int, Vec6AddRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, f64, Vec6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, f32, Vec6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, u64, Vec6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, u32, Vec6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, u16, Vec6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, u8, Vec6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, i64, Vec6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, i32, Vec6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, i16, Vec6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, i8, Vec6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, uint, Vec6SubRhs, x, y, z, w, a, b) -vec_sub_scalar_impl!(Vec6, int, Vec6SubRhs, x, y, z, w, a, b) translation_impl!(Vec6) norm_impl!(Vec6, x, y, z, w, a, b) approx_eq_impl!(Vec6, x, y, z, w, a, b) @@ -679,5 +352,5 @@ rotate_impl!(Vec6) rotate_impl!(Pnt6) transform_impl!(Vec6, Pnt6) vec_as_pnt_impl!(Vec6, Pnt6, x, y, z, w, a, b) -num_float_vec_impl!(Vec6, Vec6MulRhs, Vec6DivRhs) +num_float_vec_impl!(Vec6) absolute_vec_impl!(Vec6, x, y, z, w, a, b) diff --git a/src/structs/vec_macros.rs b/src/structs/vec_macros.rs index 0933f33b..d7ddb8f3 100644 --- a/src/structs/vec_macros.rs +++ b/src/structs/vec_macros.rs @@ -180,10 +180,10 @@ macro_rules! vec_axis_impl( ) macro_rules! vec_cast_impl( - ($t: ident, $tcast: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $tcast for $t { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Cast<$t> for $t { #[inline] - fn to(v: $t) -> $t { + fn from(v: $t) -> $t { $t::new(Cast::from(v.$comp0.clone()) $(, Cast::from(v.$compN.clone()))*) } } @@ -314,8 +314,8 @@ macro_rules! container_impl( ) macro_rules! basis_impl( - ($t: ident, $trhs: ident, $dim: expr) => ( - impl + $trhs>> Basis for $t { + ($t: ident, $dim: expr) => ( + impl> Basis for $t { #[inline] fn canonical_basis(f: |$t| -> bool) { for i in range(0u, $dim) { @@ -390,44 +390,89 @@ macro_rules! axpy_impl( ) macro_rules! add_impl( - ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Add<$t, $t> for $t { #[inline] - fn binop(left: &$t, right: &$t) -> $t { - $t::new(left.$comp0 + right.$comp0 $(, left.$compN + right.$compN)*) + fn add(&self, right: &$t) -> $t { + $t::new(self.$comp0 + right.$comp0 $(, self.$compN + right.$compN)*) + } + } + ) +) + +macro_rules! scalar_add_impl( + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + // $t against scalar + impl> Add> for $t { + #[inline] + fn add(&self, right: &N) -> $t { + $t::new(self.$comp0 + *right $(, self.$compN + *right)*) } } ) ) macro_rules! sub_impl( - ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Sub<$t, $t> for $t { #[inline] - fn binop(left: &$t, right: &$t) -> $t { - $t::new(left.$comp0 - right.$comp0 $(, left.$compN - right.$compN)*) + fn sub(&self, right: &$t) -> $t { + $t::new(self.$comp0 - right.$comp0 $(, self.$compN - right.$compN)*) + } + } + ) +) + +macro_rules! scalar_sub_impl( + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Sub> for $t { + #[inline] + fn sub(&self, right: &N) -> $t { + $t::new(self.$comp0 - *right $(, self.$compN - *right)*) } } ) ) macro_rules! mul_impl( - ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Mul<$t, $t> for $t { #[inline] - fn binop(left: &$t, right: &$t) -> $t { - $t::new(left.$comp0 * right.$comp0 $(, left.$compN * right.$compN)*) + fn mul(&self, right: &$t) -> $t { + $t::new(self.$comp0 * right.$comp0 $(, self.$compN * right.$compN)*) + } + } + ) +) + +macro_rules! scalar_mul_impl( + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Mul> for $t { + #[inline] + fn mul(&self, right: &N) -> $t { + $t::new(self.$comp0 * *right $(, self.$compN * *right)*) } } ) ) macro_rules! div_impl( - ($t: ident, $trhs: ident, $comp0: ident $(,$compN: ident)*) => ( - impl> $trhs> for $t { + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Div<$t, $t> for $t { #[inline] - fn binop(left: &$t, right: &$t) -> $t { - $t::new(left.$comp0 / right.$comp0 $(, left.$compN / right.$compN)*) + fn div(&self, right: &$t) -> $t { + $t::new(self.$comp0 / right.$comp0 $(, self.$compN / right.$compN)*) + } + } + ) +) + +macro_rules! scalar_div_impl( + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl> Div> for $t { + #[inline] + fn div(&self, right: &N) -> $t { + $t::new(self.$comp0 / *right $(, self.$compN / *right)*) } } ) @@ -801,13 +846,13 @@ macro_rules! vec_as_pnt_impl( ) macro_rules! num_float_vec_impl( - ($t: ident $(,$trhs: ident)*) => ( + ($t: ident) => ( impl NumVec for $t - where N: BaseNum + Zero $(+ $trhs>)* { + where N: BaseNum { } impl FloatVec for $t - where N: BaseNum + Zero + One + ApproxEq + BaseFloat $(+ $trhs>)* { + where N: BaseFloat + ApproxEq { } ) )