From bfb84e8fc6e905af30984096eeaa7b4b68b57e26 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sat, 19 Aug 2023 00:52:59 +0700 Subject: [PATCH] DualQuaternion: Fix to_vector self convention. By taking a ref, we can avoid an extra copy on the caller side. --- src/geometry/dual_quaternion.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/geometry/dual_quaternion.rs b/src/geometry/dual_quaternion.rs index 02fdcc76..83058032 100644 --- a/src/geometry/dual_quaternion.rs +++ b/src/geometry/dual_quaternion.rs @@ -320,7 +320,7 @@ where } impl DualQuaternion { - fn to_vector(self) -> OVector { + fn to_vector(&self) -> OVector { self.as_ref().clone().into() } } @@ -335,9 +335,9 @@ impl> AbsDiffEq for DualQuaternion { #[inline] fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool { - self.clone().to_vector().abs_diff_eq(&other.clone().to_vector(), epsilon.clone()) || + self.to_vector().abs_diff_eq(&other.to_vector(), epsilon.clone()) || // Account for the double-covering of S², i.e. q = -q - self.clone().to_vector().iter().zip(other.clone().to_vector().iter()).all(|(a, b)| a.abs_diff_eq(&-b.clone(), epsilon.clone())) + self.to_vector().iter().zip(other.to_vector().iter()).all(|(a, b)| a.abs_diff_eq(&-b.clone(), epsilon.clone())) } } @@ -354,9 +354,9 @@ impl> RelativeEq for DualQuaternion { epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool { - self.clone().to_vector().relative_eq(&other.clone().to_vector(), epsilon.clone(), max_relative.clone()) || + self.to_vector().relative_eq(&other.to_vector(), epsilon.clone(), max_relative.clone()) || // Account for the double-covering of S², i.e. q = -q - self.clone().to_vector().iter().zip(other.clone().to_vector().iter()).all(|(a, b)| a.relative_eq(&-b.clone(), epsilon.clone(), max_relative.clone())) + self.to_vector().iter().zip(other.to_vector().iter()).all(|(a, b)| a.relative_eq(&-b.clone(), epsilon.clone(), max_relative.clone())) } } @@ -368,9 +368,9 @@ impl> UlpsEq for DualQuaternion { #[inline] fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool { - self.clone().to_vector().ulps_eq(&other.clone().to_vector(), epsilon.clone(), max_ulps) || + self.to_vector().ulps_eq(&other.to_vector(), epsilon.clone(), max_ulps) || // Account for the double-covering of S², i.e. q = -q. - self.clone().to_vector().iter().zip(other.clone().to_vector().iter()).all(|(a, b)| a.ulps_eq(&-b.clone(), epsilon.clone(), max_ulps)) + self.to_vector().iter().zip(other.to_vector().iter()).all(|(a, b)| a.ulps_eq(&-b.clone(), epsilon.clone(), max_ulps)) } }