diff --git a/src/quaternion.rs b/src/quaternion.rs index 3ebaae4..c9c048d 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -17,7 +17,7 @@ use crate::vector::{EuclideanVector, Vector3}; /// A Quaternion is a combination of a scalar and a vector -/// of complex numbers. +/// of imaginary units. /// /// [S, V] = [S, Xi + Yj + Zk] /// @@ -28,9 +28,9 @@ use crate::vector::{EuclideanVector, Vector3}; /// /// | | | /// |:-------:|:-------:| -/// | ij = 1 | ik = -1 | -/// | jk = 1 | kj = -1 | -/// | ki = 1 | ji = -1 | +/// | ij = k | ji = -k | +/// | jk = i | kj = -i | +/// | ki = j | ik = -j | #[derive(Clone, Copy)] pub struct Quaternion { @@ -274,6 +274,11 @@ impl Quaternion where T: Trig /// conjugate of this Quaternion. pub fn invert(&self) -> Quaternion { + // This only works for unit quaternions and the normalize here is doing + // the heavy lifting of fixing my drift for my skeleton rotations. + // + // JTS: To reuse this code for other domains, this needs to become the + // conjugate divided by the magnitude squared. self.conjugate().normalize() }