From e0cc7ff21b0db6aa22f35bd3dbf7c696313b5f5f Mon Sep 17 00:00:00 2001 From: Eduard Bopp Date: Fri, 28 Jul 2017 18:57:44 +0200 Subject: [PATCH] Fix TCategory implementation for TAffine Closes #271. --- src/geometry/transform.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/geometry/transform.rs b/src/geometry/transform.rs index 8d311375..5ff2d85e 100644 --- a/src/geometry/transform.rs +++ b/src/geometry/transform.rs @@ -100,9 +100,10 @@ impl TCategory for TAffine { D: DimName, S: Storage, N::Epsilon: Copy { - mat.is_invertible() && - mat[(D::dim(), D::dim())] == N::one() && - (0 .. D::dim()).all(|i| mat[(D::dim(), i)].is_zero()) + let last = D::dim() - 1; + mat.is_invertible() && + mat[(last, last)] == N::one() && + (0 .. last).all(|i| mat[(last, i)].is_zero()) } } @@ -334,3 +335,15 @@ impl TransformBase self.matrix_mut_unchecked() } } + +#[cfg(test)] +mod tests { + use super::*; + use ::core::Matrix4; + + #[test] + fn checks_homogeneous_invariants_of_square_identity_matrix() { + assert!(TAffine::check_homogeneous_invariants(&Matrix4::::identity())); + } + +}