Quaternion
Quaternions are an alternate way to describe orientation or rotations in 3D space using an ordered set of four numbers. They have the ability to uniquely describe any three-dimensional rotation about an arbitrary axis and do not suffer from gimbal lock
Unit quaternion
A unit quaternion like unit vector is simply a vector with length (magnitude) equal to 1, but pointing in the same direction as the original vector.
quaternion: \(\(q = w + xi + yj + zk\)\)
as a vector \(\(q = (w, x, y, z)\)\)
calc the norm \(\(\|q\| = \sqrt{w^2 + x^2 + y^2 + z^2}\)\)
calc unit quaternion \(\(q_{unit} = \frac{q}{\|q\|} = \left(\frac{w}{\|q\|}, \frac{x}{\|q\|}, \frac{y}{\|q\|}, \frac{z}{\|q\|}\right)\)\)
code example
Conjugate
A quaternion is: \(\(q = (x, y, z, w)\)\)
The conjugate is: \(\(q^* = (-x, -y, -z, w)\)\)
flip the signs of x, y, z, keep w the same.
Slerp
Spherical Linear intERPolation (SLERP) is a method to smoothly interpolate between two orientations (unit quaternions). - SLERP traces the shortest arc along that sphere between them
- At t=0 → result = q0
- At t=1 → result = q1
- At t=0.5 → halfway rotation between them.
Demo: using scipy
Inverse
unit quaternion
If q is a unit quaternion (∥q∥=1), then the conjugate is also the inverse.
when not unit length
Multiple
by vector
we treat the vector as pure quaternion
Numpy Example
by quaternion
Quaternion multiplication is used to combine rotations in 3D space
Warning
