added Quaternion accessors for r,i,j,k, refactored conjugate to use imag (#551)

This commit is contained in:
adamnemecek 2019-02-23 07:03:01 -08:00 committed by Sébastien Crozet
parent 20e9c6f480
commit 704331be4f
1 changed files with 7 additions and 7 deletions

View File

@ -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
@ -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.