From 65e744c8cdc470ca0bb5f5421c87a81e3870c734 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Tue, 10 May 2016 21:55:11 +1000 Subject: [PATCH 1/2] Remove self inversion methods --- src/rotation.rs | 10 ---------- src/structure.rs | 6 ------ src/transform.rs | 7 ------- tests/matrix.rs | 21 --------------------- 4 files changed, 44 deletions(-) diff --git a/src/rotation.rs b/src/rotation.rs index 340fb0e..6a2dba5 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -198,11 +198,6 @@ impl Rotation> for Basis2 { // to be faster #[inline] fn invert(&self) -> Basis2 { Basis2 { mat: self.mat.invert().unwrap() } } - - // TODO: we know the matrix is orthogonal, so this could be re-written - // to be faster - #[inline] - fn invert_self(&mut self) { self.mat.invert_self(); } } impl ApproxEq for Basis2 { @@ -289,11 +284,6 @@ impl Rotation> for Basis3 { // to be faster #[inline] fn invert(&self) -> Basis3 { Basis3 { mat: self.mat.invert().unwrap() } } - - // TODO: we know the matrix is orthogonal, so this could be re-written - // to be faster - #[inline] - fn invert_self(&mut self) { self.mat.invert_self(); } } impl ApproxEq for Basis3 { diff --git a/src/structure.rs b/src/structure.rs index 0e77d1a..c707551 100644 --- a/src/structure.rs +++ b/src/structure.rs @@ -509,12 +509,6 @@ pub trait SquareMatrix where #[must_use] fn invert(&self) -> Option; - /// Invert this matrix in-place. - #[inline] - fn invert_self(&mut self) { - *self = self.invert().expect("Attempted to invert a matrix with zero determinant."); - } - /// Test if this matrix is invertible. #[inline] fn is_invertible(&self) -> bool { !self.determinant().approx_eq(&Self::Scalar::zero()) } diff --git a/src/transform.rs b/src/transform.rs index feb01da..5427b69 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -60,13 +60,6 @@ pub trait Transform: Sized { fn concat_self(&mut self, other: &Self) { *self = Self::concat(self, other); } - - /// Invert this transform in-place, failing if the transformation is not - /// invertible. - #[inline] - fn to_inverse(&mut self) { - *self = self.inverse_transform().unwrap() - } } /// A generic transformation consisting of a rotation, diff --git a/tests/matrix.rs b/tests/matrix.rs index 10e2c83..d5c6f06 100644 --- a/tests/matrix.rs +++ b/tests/matrix.rs @@ -129,13 +129,6 @@ pub mod matrix2 { 0.0f64, 5.0f64).invert().is_none()); } - #[test] - fn test_invert_self() { - let mut mut_a = A; - mut_a.invert_self(); - assert_eq!(mut_a, A.invert().unwrap()); - } - #[test] fn test_predicates() { assert!(Matrix2::::identity().is_identity()); @@ -300,13 +293,6 @@ pub mod matrix3 { 0.0f64, 0.0f64, 1.0f64)); } - #[test] - fn test_invert_self() { - let mut mut_c = C; - mut_c.invert_self(); - assert_eq!(mut_c, C.invert().unwrap()); - } - #[test] fn test_predicates() { assert!(Matrix3::::identity().is_identity()); @@ -579,13 +565,6 @@ pub mod matrix4 { assert!((mat_f.invert().unwrap() * mat_f).is_identity()); } - #[test] - fn test_invert_self() { - let mut mut_c = C; - mut_c.invert_self(); - assert_eq!(mut_c, C.invert().unwrap()); - } - #[test] fn test_predicates() { assert!(Matrix4::::identity().is_identity()); From 266f4c1d0d29596f8176a4f5cc4da90ac5ac0185 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Tue, 10 May 2016 21:55:20 +1000 Subject: [PATCH 2/2] Fix export warning --- src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index df1db23..58ee237 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,7 +50,7 @@ //! use cgmath::prelude::*; //! ``` -extern crate num_traits as _num_traits; +pub extern crate num_traits; extern crate rustc_serialize; extern crate rand; @@ -75,7 +75,6 @@ pub use projection::*; // Modules pub mod conv; -pub use _num_traits as num_traits; pub mod prelude; mod macros;