diff --git a/src/mat.rs b/src/mat.rs index d244f9a..cd474f3 100644 --- a/src/mat.rs +++ b/src/mat.rs @@ -94,21 +94,6 @@ pub mod Mat2 { Mat2::new(value, _0, _0, value) } - - #[inline(always)] - pub pure fn zero() -> Mat2 { - let _0 = cast(0); - Mat2::new(_0, _0, - _0, _0) - } - - #[inline(always)] - pub pure fn identity() -> Mat2 { - let _0 = cast(0); - let _1 = cast(1); - Mat2::new(_1, _0, - _0, _1) - } } pub impl Mat2: Matrix, Vec2> { @@ -224,7 +209,7 @@ pub impl Mat2: NumericMatrix_NxN> { #[inline(always)] pure fn is_identity() -> bool { - self.default_eq(&Mat2::identity()) + self.default_eq(&NumericMatrix_NxN::identity()) } #[inline(always)] @@ -242,7 +227,7 @@ pub impl Mat2: NumericMatrix_NxN> { #[inline(always)] pure fn is_rotated() -> bool { - !self.default_eq(&Mat2::identity()) + !self.default_eq(&NumericMatrix_NxN::identity()) } #[inline(always)] @@ -336,23 +321,6 @@ pub mod Mat3 { m[1][0], m[1][1], _0, _0, _0, _1) } - - #[inline(always)] - pub pure fn zero() -> Mat3 { - let _0 = cast(0); - Mat3::new(_0, _0, _0, - _0, _0, _0, - _0, _0, _0) - } - - #[inline(always)] - pub pure fn identity() -> Mat3 { - let _0 = cast(0); - let _1 = cast(1); - Mat3::new(_1, _0, _0, - _0, _1, _0, - _0, _0, _1) - } } pub impl Mat3: Matrix, Vec3> { @@ -479,7 +447,7 @@ pub impl Mat3: NumericMatrix_NxN> { #[inline(always)] pure fn is_identity() -> bool { - self.default_eq(&Mat3::identity()) + self.default_eq(&NumericMatrix_NxN::identity()) } #[inline(always)] @@ -509,7 +477,7 @@ pub impl Mat3: NumericMatrix_NxN> { #[inline(always)] pure fn is_rotated() -> bool { - !self.default_eq(&Mat3::identity()) + !self.default_eq(&NumericMatrix_NxN::identity()) } #[inline(always)] @@ -658,25 +626,6 @@ pub mod Mat4 { m[2][0], m[2][1], m[2][2], _0, _0, _0, _0, _1) } - - #[inline(always)] - pub pure fn zero() -> Mat4 { - let _0 = cast(0); - Mat4::new(_0, _0, _0, _0, - _0, _0, _0, _0, - _0, _0, _0, _0, - _0, _0, _0, _0) - } - - #[inline(always)] - pub pure fn identity() -> Mat4 { - let _0 = cast(0); - let _1 = cast(1); - Mat4::new(_1, _0, _0, _0, - _0, _1, _0, _0, - _0, _0, _1, _0, - _0, _0, _0, _1) - } } pub impl Mat4: Matrix, Vec4> { @@ -812,7 +761,7 @@ pub impl Mat4: NumericMatrix_NxN(); + let mut inv: Mat4 = NumericMatrix_NxN::identity(); // Find largest pivot column j among rows j..3 for uint::range(0, 4) |j| { @@ -868,7 +817,7 @@ pub impl Mat4: NumericMatrix_NxN bool { - self.default_eq(&Mat4::identity()) + self.default_eq(&NumericMatrix_NxN::identity()) } #[inline(always)] @@ -912,7 +861,7 @@ pub impl Mat4: NumericMatrix_NxN bool { - !self.default_eq(&Mat4::identity()) + !self.default_eq(&NumericMatrix_NxN::identity()) } #[inline(always)] diff --git a/src/test/test_mat.rs b/src/test/test_mat.rs index 8f08fec..83b0fca 100644 --- a/src/test/test_mat.rs +++ b/src/test/test_mat.rs @@ -60,11 +60,13 @@ fn test_Mat2() { // fuzzy_eq // eq - assert Mat2::identity::().is_identity(); - assert Mat2::identity::().is_symmetric(); - assert Mat2::identity::().is_diagonal(); - assert !Mat2::identity::().is_rotated(); - assert Mat2::identity::().is_invertible(); + let ident: Mat2 = NumericMatrix_NxN::identity(); + + assert ident.is_identity(); + assert ident.is_symmetric(); + assert ident.is_diagonal(); + assert !ident.is_rotated(); + assert ident.is_invertible(); assert !a.is_identity(); assert !a.is_symmetric(); @@ -159,9 +161,6 @@ fn test_Mat3() { 7f, 8f, 9f); assert a.invert().is_none(); - - assert option::unwrap(Mat3::identity::().invert()) - == Mat3::identity::(); assert option::unwrap(Mat3::new(2f, 4f, 6f, 0f, 2f, 4f, @@ -169,15 +168,20 @@ fn test_Mat3() { == Mat3::new(0.5f, -1f, 1f, 0f, 0.5f, -2f, 0f, 0f, 1f); + + let ident: Mat3 = NumericMatrix_NxN::identity(); + + assert option::unwrap(ident.invert()) == ident; + // exact_eq // fuzzy_eq // eq - assert Mat3::identity::().is_identity(); - assert Mat3::identity::().is_symmetric(); - assert Mat3::identity::().is_diagonal(); - assert !Mat3::identity::().is_rotated(); - assert Mat3::identity::().is_invertible(); + assert ident.is_identity(); + assert ident.is_symmetric(); + assert ident.is_diagonal(); + assert !ident.is_rotated(); + assert ident.is_invertible(); assert !a.is_identity(); assert !a.is_symmetric(); @@ -301,19 +305,20 @@ fn test_Mat4() { -4f, 8f, -4f, 0f, 4f, -8f, 4f, 8f, -3f, 4f, 1f, -8f).mul_t(0.125f); + + let ident: Mat4 = NumericMatrix_NxN::identity(); - assert option::unwrap(Mat4::identity::().invert()) - == Mat4::identity::(); + assert option::unwrap(ident.invert()) == ident; // exact_eq // fuzzy_eq // eq - assert Mat4::identity::().is_identity(); - assert Mat4::identity::().is_symmetric(); - assert Mat4::identity::().is_diagonal(); - assert !Mat4::identity::().is_rotated(); - assert Mat4::identity::().is_invertible(); + assert ident.is_identity(); + assert ident.is_symmetric(); + assert ident.is_diagonal(); + assert !ident.is_rotated(); + assert ident.is_invertible(); assert !a.is_identity(); assert !a.is_symmetric();