From d9675f7c7ed01fce695ebe2f8b8f74bf012ce394 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Wed, 30 Sep 2015 20:39:10 +1000 Subject: [PATCH] Formatting --- src/matrix.rs | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/matrix.rs b/src/matrix.rs index 6ebc659..433d384 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -249,9 +249,7 @@ impl> Matrix4 { } } -pub trait Matrix + 'static>: Array2 - + ApproxEq - + Sized // where +pub trait Matrix + 'static>: Array2 + ApproxEq + Sized // where // FIXME: blocked by rust-lang/rust#20671 // // for<'a, 'b> &'a Self: Add<&'b Self, Output = Self>, @@ -733,24 +731,16 @@ impl Matrix> for Matrix4 { fn invert(&self) -> Option> { let det = self.determinant(); - if !det.approx_eq(&S::zero()) { + if det.approx_eq(&S::zero()) { None } else { let inv_det = S::one() / det; let t = self.transpose(); let cf = |i, j| { let mat = match i { - 0 => Matrix3::from_cols(t.y.truncate_n(j), - t.z.truncate_n(j), - t.w.truncate_n(j)), - 1 => Matrix3::from_cols(t.x.truncate_n(j), - t.z.truncate_n(j), - t.w.truncate_n(j)), - 2 => Matrix3::from_cols(t.x.truncate_n(j), - t.y.truncate_n(j), - t.w.truncate_n(j)), - 3 => Matrix3::from_cols(t.x.truncate_n(j), - t.y.truncate_n(j), - t.z.truncate_n(j)), - _ => panic!("out of range") + 0 => Matrix3::from_cols(t.y.truncate_n(j), t.z.truncate_n(j), t.w.truncate_n(j)), + 1 => Matrix3::from_cols(t.x.truncate_n(j), t.z.truncate_n(j), t.w.truncate_n(j)), + 2 => Matrix3::from_cols(t.x.truncate_n(j), t.y.truncate_n(j), t.w.truncate_n(j)), + 3 => Matrix3::from_cols(t.x.truncate_n(j), t.y.truncate_n(j), t.z.truncate_n(j)), + _ => panic!("out of range"), }; let sign = if (i + j) & 1 == 1 { -S::one() } else { S::one() }; mat.determinant() * sign * inv_det @@ -760,9 +750,6 @@ impl Matrix> for Matrix4 { cf(1, 0), cf(1, 1), cf(1, 2), cf(1, 3), cf(2, 0), cf(2, 1), cf(2, 2), cf(2, 3), cf(3, 0), cf(3, 1), cf(3, 2), cf(3, 3))) - - } else { - None } }