added Quaternion accessors for r,i,j,k, refactored conjugate to use imag (#551)
This commit is contained in:
parent
20e9c6f480
commit
704331be4f
@ -124,6 +124,12 @@ impl<N: Real> Quaternion<N> {
|
|||||||
Self::from(self.coords.normalize())
|
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.
|
/// The conjugate of this quaternion.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
@ -135,13 +141,7 @@ impl<N: Real> Quaternion<N> {
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn conjugate(&self) -> Self {
|
pub fn conjugate(&self) -> Self {
|
||||||
let v = Vector4::new(
|
Self::from_parts(self.w, -self.imag())
|
||||||
-self.coords[0],
|
|
||||||
-self.coords[1],
|
|
||||||
-self.coords[2],
|
|
||||||
self.coords[3],
|
|
||||||
);
|
|
||||||
Self::from(v)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inverts this quaternion if it is not zero.
|
/// Inverts this quaternion if it is not zero.
|
||||||
|
Loading…
Reference in New Issue
Block a user