Merge pull request #352 from bjz/remove-invert-self

Remove invert self methods
This commit is contained in:
Brendan Zabarauskas 2016-05-11 15:10:24 +10:00
commit 32baeea31f
5 changed files with 1 additions and 46 deletions

View file

@ -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;

View file

@ -198,11 +198,6 @@ impl<S: BaseFloat> Rotation<Point2<S>> for Basis2<S> {
// to be faster
#[inline]
fn invert(&self) -> Basis2<S> { 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<S: BaseFloat> ApproxEq for Basis2<S> {
@ -289,11 +284,6 @@ impl<S: BaseFloat> Rotation<Point3<S>> for Basis3<S> {
// to be faster
#[inline]
fn invert(&self) -> Basis3<S> { 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<S: BaseFloat> ApproxEq for Basis3<S> {

View file

@ -509,12 +509,6 @@ pub trait SquareMatrix where
#[must_use]
fn invert(&self) -> Option<Self>;
/// 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()) }

View file

@ -60,13 +60,6 @@ pub trait Transform<P: EuclideanSpace>: 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,

View file

@ -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::<f64>::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::<f64>::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::<f64>::identity().is_identity());