From 679db701c9dded2af3e9869e6be440b258f068a5 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Thu, 25 Jul 2013 12:38:43 +1000 Subject: [PATCH] Impl ApproxEq for rotation matricies using macros --- src/transform/rotation.rs | 39 ++++----------------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/src/transform/rotation.rs b/src/transform/rotation.rs index ca662d3..e70f5d7 100644 --- a/src/transform/rotation.rs +++ b/src/transform/rotation.rs @@ -69,6 +69,8 @@ pub struct RotationMat2 { priv mat: Mat2 } +impl_approx!(RotationMat2 { mat }) + impl RotationMat2 { #[inline] pub fn as_mat2<'a>(&'a self) -> & 'a Mat2 { @@ -118,24 +120,6 @@ impl Neg> for RotationMat2 { } } -impl> ApproxEq for RotationMat2 { - #[inline] - pub fn approx_epsilon() -> T { - ApproxEq::approx_epsilon::() - } - - #[inline] - pub fn approx_eq(&self, other: &RotationMat2) -> bool { - self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) - } - - #[inline] - pub fn approx_eq_eps(&self, other: &RotationMat2, epsilon: &T) -> bool { - self.mat.approx_eq_eps(&other.mat, epsilon) - } -} - - impl Rotation3 for Quat { pub fn rotate_point3(&self, point: Point3) -> Point3 { Point3::from_vec3(self.mul_v(point.as_vec3())) @@ -166,6 +150,8 @@ pub struct RotationMat3 { priv mat: Mat3 } +impl_approx!(RotationMat3 { mat }) + impl RotationMat3 { #[inline] pub fn as_mat3<'a>(&'a self) -> & 'a Mat3 { @@ -229,23 +215,6 @@ impl RotationMat3 { } } -impl> ApproxEq for RotationMat3 { - #[inline] - pub fn approx_epsilon() -> T { - ApproxEq::approx_epsilon::() - } - - #[inline] - pub fn approx_eq(&self, other: &RotationMat3) -> bool { - self.approx_eq_eps(other, &ApproxEq::approx_epsilon::()) - } - - #[inline] - pub fn approx_eq_eps(&self, other: &RotationMat3, epsilon: &T) -> bool { - self.mat.approx_eq_eps(&other.mat, epsilon) - } -} - /// Euler angles /// /// # Fields