From 074cb2c36f7e2d10fbc62e9477b03ec89e09e77b Mon Sep 17 00:00:00 2001 From: Mark Hintz Date: Sun, 1 May 2016 14:59:38 +0200 Subject: [PATCH] Change the name of methods on the Transform trait to avoid clashes Transform::invert becomes Transform::inverse_transform, and Transform::invert_self becomes Transform::to_inverse. Tests passing for me now --- src/matrix.rs | 6 +++--- src/transform.rs | 10 +++++----- tests/transform.rs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/matrix.rs b/src/matrix.rs index 67d6295..8b98632 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -778,7 +778,7 @@ impl Transform> for Matrix3 { self * other } - fn invert(&self) -> Option> { + fn inverse_transform(&self) -> Option> { SquareMatrix::invert(self) } } @@ -805,7 +805,7 @@ impl Transform> for Matrix3 { self * other } - fn invert(&self) -> Option> { + fn inverse_transform(&self) -> Option> { SquareMatrix::invert(self) } } @@ -831,7 +831,7 @@ impl Transform> for Matrix4 { self * other } - fn invert(&self) -> Option> { + fn inverse_transform(&self) -> Option> { SquareMatrix::invert(self) } } diff --git a/src/transform.rs b/src/transform.rs index f7c1833..feb01da 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -53,7 +53,7 @@ pub trait Transform: Sized { fn concat(&self, other: &Self) -> Self; /// Create a transform that "un-does" this one. - fn invert(&self) -> Option; + fn inverse_transform(&self) -> Option; /// Combine this transform with another, in-place. #[inline] @@ -64,8 +64,8 @@ pub trait Transform: Sized { /// Invert this transform in-place, failing if the transformation is not /// invertible. #[inline] - fn invert_self(&mut self) { - *self = self.invert().unwrap() + fn to_inverse(&mut self) { + *self = self.inverse_transform().unwrap() } } @@ -122,7 +122,7 @@ impl> Transform

for Decomposed } } - fn invert(&self) -> Option> { + fn inverse_transform(&self) -> Option> { if self.scale.approx_eq(&P::Scalar::zero()) { None } else { @@ -196,7 +196,7 @@ impl Transform> for AffineMatrix3 { } #[inline] - fn invert(&self) -> Option> { + fn inverse_transform(&self) -> Option> { SquareMatrix::invert(& self.mat).map(|m| AffineMatrix3{ mat: m }) } } diff --git a/tests/transform.rs b/tests/transform.rs index 8fa558d..e83372f 100644 --- a/tests/transform.rs +++ b/tests/transform.rs @@ -26,7 +26,7 @@ fn test_invert() { rot: Quaternion::new(0.5f64,0.5,0.5,0.5), disp: Vector3::new(6.0f64,-7.0,8.0) }; - let ti = t.invert().expect("Expected successful inversion"); + let ti = t.inverse_transform().expect("Expected successful inversion"); let vt = t.transform_vector(v); assert!(v.approx_eq(&ti.transform_vector(vt))); }