Skip to content

Commit

Permalink
added Quaternion accessors for r,i,j,k, refactored conjugate to use i…
Browse files Browse the repository at this point in the history
…mag (#551)
  • Loading branch information
adamnemecek authored and sebcrozet committed Feb 23, 2019
1 parent 20e9c6f commit 704331b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/geometry/quaternion.rs
Expand Up @@ -124,6 +124,12 @@ impl<N: Real> Quaternion<N> {
Self::from(self.coords.normalize())
}

/// The imaginary part of this quaternion.
#[inline]
pub fn imag(&self) -> Vector3<N> {
self.coords.xyz()
}

/// The conjugate of this quaternion.
///
/// # Example
Expand All @@ -135,13 +141,7 @@ impl<N: Real> Quaternion<N> {
/// ```
#[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.
Expand Down

0 comments on commit 704331b

Please sign in to comment.