Euler angles, axis-angle and quaternions
$SO(3)$ is a 3-dimensional curved space, and there is a theorem (a consequence of its topology) that no set of 3 numbers can cover it smoothly and without a singularity somewhere. Every parametrization therefore trades something away. Euler angles are readable but lock up. The rotation vector has a seam at $\pi$. Quaternions spend a fourth number to remove every singularity, and in return count each rotation twice. This part shows each trade in action and ends with a table for choosing. The Lie-group view settles the confusion: parametrizations are for storage and I/O, and the group is what you compute with.
Euler angles and gimbal lock
Three readable numbers, one fatal pose
The aerospace convention writes $R = R_z(\psi)\,R_y(\theta)\,R_x(\phi)$: yaw about the world vertical, then pitch about the new $y$ axis, then roll about the newest $x$ axis. Each angle has a physical meaning, which is why Euler angles are the right choice for displaying an attitude to a person. The trouble is the map from angle rates to body angular velocity:
At pitch $\theta = \pm 90^\circ$ the determinant vanishes: the yaw axis and the roll axis point the same way, and the three angle rates can only produce two independent body rotations. That is gimbal lock. Nothing is wrong with the body, which can rotate any way it likes; the coordinates have lost a direction. Near lock, a small, ordinary body rotation needs enormous angle rates, and any filter that integrates Euler angles blows up. Slide pitch toward $90^\circ$ and watch the yaw and roll circles merge while the required rates explode.
The rotation vector, revisited
Minimal, nearly singularity-free, and not closed under addition
The rotation vector $\omega = \theta k$ from Part 5 is the Lie-algebra coordinate itself. It has three numbers and is smooth everywhere inside the ball $\lVert\omega\rVert < \pi$. Its one seam is the antipodal gluing at $\lVert\omega\rVert = \pi$. Its weakness is composition: $\operatorname{Exp}(a)\operatorname{Exp}(b) \ne \operatorname{Exp}(a+b)$, and the correction is the BCH series. It is the ideal coordinate for a small quantity, such as an update step, an error, a covariance or a velocity, and a poor one for storing a large orientation that will be composed many times. That split, a large state kept in the group plus a small error kept as a rotation vector, is exactly how modern estimators work (Parts 10–12).
Quaternions and the double cover
Four numbers, no singularity, every rotation twice
A unit quaternion $q = (w, x, y, z)$ with $w^2+x^2+y^2+z^2 = 1$ is a point on the 3-sphere $S^3$. Rotation by $\theta$ about $k$ is encoded with half the angle:
Quaternions are a Lie group in their own right. $S^3$ with the quaternion product is $SU(2)$, the group of $2\times2$ unitary matrices, and its Lie algebra is the same $\mathbb{R}^3$ as $\mathfrak{so}(3)$. The exponential is $\operatorname{Exp}(\omega) = (\cos\tfrac{\lVert\omega\rVert}2, \sin\tfrac{\lVert\omega\rVert}2\tfrac{\omega}{\lVert\omega\rVert})$. The map $q \mapsto R(q)$ is two-to-one, because the half-angle means $q$ and $-q$ produce the same rotation. So $S^3$ double-covers $SO(3)$. That doubling is exactly what removes the seam: $S^3$ has no antipodal gluing, so quaternions can be interpolated, integrated and differentiated with no special cases anywhere.
The demo spins a body steadily about a fixed axis. At $360^\circ$ the body is back where it began, but the quaternion is at $-q_0$; only at $720^\circ$ does it return to $q_0$. The ribbon connecting the body to a fixed base is the classic belt trick. After one turn it holds a twist that no sliding can remove; after two turns the twist can be undone completely. That is the topological fact that loops in $SO(3)$ come in two kinds, and the quaternion keeps track of which.
Left: the body and its ribbon to a fixed base; each slice of the ribbon is oriented along the shortest quaternion path from the base. Right: the four quaternion components over two full turns, with the current angle marked.
Interpolating between two orientations
slerp, nlerp and Euler lerp
Blending orientations is needed everywhere: animation keyframes, trajectory smoothing, and timestamp alignment between a camera and an IMU. There are three common recipes:
Slerp (spherical linear interpolation) is the geodesic $R_0\operatorname{Exp}(t\operatorname{Log}(R_0^\top R_1))$ written in quaternions. It follows the shortest path at constant angular speed. nlerp follows the same path, because the normalized chord projects onto the same great circle, but it speeds up in the middle. It is cheaper and fine for small gaps. Euler lerp takes a different path entirely, and it can swing wildly when the endpoints are near lock. The traces show where each one sends the body's nose (its $x$ axis), and the plot shows the angular speed along each.
Quaternion pitfalls: signs, order and drift
What goes wrong in real code
Because $q$ and $-q$ are the same rotation, any operation that treats quaternions as 4-vectors has to be told which sign to use. Averaging is the classic trap. Five noisy measurements of one orientation, where a couple happen to be stored as $-q$, average component-wise to nearly nothing. Aligning signs first (flip any $q_i$ with $q_i\cdot q_1 < 0$) fixes it. The robust method used in attitude estimation (Markley et al.) avoids the problem entirely: the average is the dominant eigenvector of $\sum_i q_iq_i^\top$, and $q q^\top$ is the same for both signs.
Three more conventions to check before trusting a quaternion from someone else's code:
Choosing a representation
| Rotation matrix | Unit quaternion | Rotation vector | Euler angles | |
|---|---|---|---|---|
| Numbers stored | 9 | 4 | 3 | 3 |
| Constraint | $R^\top R=I$, $\det R=1$ | $\lVert q\rVert = 1$ | none (wrap at $\pi$) | none (wrap, lock) |
| Singularities | none | none (double cover) | at $\lVert\omega\rVert=\pi$ | gimbal lock at $\theta=\pm90^\circ$ |
| Compose | matrix product (27 mult.) | quaternion product (16 mult.) | via BCH / Exp–Log | via matrices |
| Rotate a vector | 9 mult. | ~15–18 mult. (or convert) | Rodrigues | via matrices |
| Interpolate | via Log/Exp | slerp | only when small | poor |
| Renormalize | SVD or Gram–Schmidt | divide by the norm | — | — |
| Best for | transforming many points; clarity | state storage, integration, interpolation | errors, steps, covariances | display and human input only |
The Lie-group view resolves what could look like a contest. Store the state as a group element (matrix or quaternion, whichever is convenient). Express every small quantity, meaning steps, errors, noise and velocities, as a rotation vector in the tangent space. Move between the two only with Exp and Log. Use Euler angles only at the human interface.