Quaternions
A quaternion is a 4D number system extension of complex numbers that provides a compact, numerically stable way to represent 3D rotations without the woes of gimbal lock. A quaternion is written
&\mathbf{i}^2=\mathbf{j}^2=\mathbf{k}^2=\mathbf{i}\mathbf{j}\mathbf{k}=-1, \\ &\mathbf{i}\mathbf{j}=\mathbf{k},\quad \mathbf{j}\mathbf{k}=\mathbf{i},\quad \mathbf{k}\mathbf{i}=\mathbf{j}, \\ &\mathbf{j}\mathbf{i}=-\mathbf{k},\quad \mathbf{k}\mathbf{j}=-\mathbf{i},\quad \mathbf{i}\mathbf{k}=-\mathbf{j}. \end{align*}$$ Note that pairwise multiplication is non-commutitative. A unit quaternion encodes a rotation by an angle $\theta$ about a unit axis $\hat{a}\in\mathbb{R}^3$ via $$q = \left(\cos\frac{\theta}{2},\; \hat{a}\,\sin\frac{\theta}{2}\right).$$ In this representation, $q$ and $-q$ correspond to the **same physical rotation**, so the mapping from unit quaternions to $SO(3)$ is two-to-one. Quaternions compose rotations through quaternion multiplication: if $q_1$ and $q_2$ represent rotations $R_1$ and $R_2$, then $q_2 q_1$ represents the composed rotation $R_2\circ R_1$ (order matters). The inverse rotation is given by the quaternion **conjugate**: $$q^* = (w,\; -\mathbf{u}),\qquad q^{-1}=q^*\ \text{for}\ \lVert q\rVert=1.$$
where is the scalar part and is the vector part. For rotations, one uses unit quaternions satisfying . The quaternion basis elements satisfy:
Quaternions avoid the singularities of Euler angles (no gimbal lock in the representation) and are widely used for orientation integration, interpolation, and filtering. Converting to a rotation matrix is standard and yields an orthonormal matrix with , while conversion from back to requires choosing a consistent sign convention because of the ambiguity.
Intuition
Unit quaternions live on the 3-sphere , which double-covers : each rotation corresponds to two antipodal quaternions . This 4-parameter representation trades one extra parameter for complete singularity freedom—unlike 3-parameter representations (Euler angles, exponential coordinates), there is no configuration where the parameterization degenerates.
The half-angle in is not arbitrary—it ensures that the quaternion product correctly composes rotations. Geometrically, wraps around twice: as goes from to , traverses a semicircle on from to , and the return trip corresponds to .
Properties
(Quaternion Multiplication) For and :
The cross product term is what makes quaternion multiplication non-commutative.
(Rotation Action) To rotate a vector by quaternion , embed as the pure quaternion and compute (quaternion sandwich product). This is equivalent to where is the corresponding rotation matrix.
(Quaternion to Matrix) For :
(SLERP) Spherical linear interpolation between and at parameter :
where . This produces constant angular velocity interpolation—the optimal path on .
(Angular Velocity) For a unit quaternion trajectory , the body angular velocity is and the spatial angular velocity is , where extracts the vector part.
Examples
Composing Two 90° Rotations
(90° about ).
(90° about ).Quaternion product Using the multiplication formula: . .
Result: , which represents a 120° rotation about the axis (since ).