From 704331be4fbce372dedbad07798086d4dccf9cc2 Mon Sep 17 00:00:00 2001 From: adamnemecek Date: Sat, 23 Feb 2019 07:03:01 -0800 Subject: [PATCH] added Quaternion accessors for r,i,j,k, refactored conjugate to use imag (#551) --- src/geometry/quaternion.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/geometry/quaternion.rs b/src/geometry/quaternion.rs index b58d885c5..49656b2cd 100644 --- a/src/geometry/quaternion.rs +++ b/src/geometry/quaternion.rs @@ -124,6 +124,12 @@ impl Quaternion { Self::from(self.coords.normalize()) } + /// The imaginary part of this quaternion. + #[inline] + pub fn imag(&self) -> Vector3 { + self.coords.xyz() + } + /// The conjugate of this quaternion. /// /// # Example @@ -135,13 +141,7 @@ impl Quaternion { /// ``` #[inline] pub fn conjugate(&self) -> Self { - let v = Vector4::new( - -self.coords[0], - -self.coords[1], - -self.coords[2], - self.coords[3], - ); - Self::from(v) + Self::from_parts(self.w, -self.imag()) } /// Inverts this quaternion if it is not zero.