No jobs
Core 12 min 2 of 3

Four ways to write a rotation

Matrices, axis–angle, quaternions and Euler angles — each optimal for something, none for everything.

What this repairs

The belief that quaternions are "better" and Euler angles are "bad", rather than each being adapted to a different job.

A rotation in 3D has three degrees of freedom. Every representation is a compromise between that number and the operations you want to be cheap.

Numbers Constraint Good at Bad at
Matrix RR 9 RR=IR^\top R = I , detR=1\det R = 1 applying to vectors, composing storage, staying valid under drift
Axis–angle ω\boldsymbol{\omega} 3 none minimal, natural for increments composing, singular at 2π2\pi
Quaternion qq 4 q=1\lVert q \rVert = 1 composing, interpolating, stability reading by eye, sign ambiguity
Euler (ψ,θ,ϕ)(\psi, \theta, \phi) 3 none human interfaces everything else

The three-number representations cannot be globally free of singularities — this is a topological fact about SO(3)SO(3) , not a failure of imagination — which is why the well-behaved representations carry a redundant number and a constraint.

Axis–angle to matrix (Rodrigues)

  1. v=(kv)k,v=vv\mathbf{v}_{\parallel} = (\mathbf{k}\cdot\mathbf{v})\,\mathbf{k}, \qquad \mathbf{v}_{\perp} = \mathbf{v} - \mathbf{v}_{\parallel}

    Split the vector into components along and across the rotation axis k. Only the perpendicular part moves.

  2. v=cosθv+sinθ(k×v)\mathbf{v}_{\perp}' = \cos\theta\,\mathbf{v}_{\perp} + \sin\theta\,(\mathbf{k}\times\mathbf{v})

    The perpendicular part rotates in its plane, with k × v supplying the perpendicular direction of unit length.

  3. R=I+sinθ[k]×+(1cosθ)[k]×2R = I + \sin\theta\,[\mathbf{k}]_\times + (1-\cos\theta)\,[\mathbf{k}]_\times^2

    Collect terms and write the cross product as the skew-symmetric matrix [k]ₓ. Three numbers in, a valid rotation matrix out — always, with no constraint to enforce.

Check yourself

You store orientations as 3×33\times3 matrices and integrate small updates over thousands of steps. What goes wrong, and what fixes it?

Show answer

Floating-point error accumulates and RR drifts away from orthogonality — it starts scaling and shearing slightly. Symptoms: vectors changing length under "rotation", and RR^\top no longer being the inverse. Fixes, in increasing order of principle: periodic re-orthonormalisation (Gram–Schmidt or the SVD projection RUVR \leftarrow UV^\top ); storing a quaternion and re-normalising, which is one constraint instead of six; or composing updates as RRexp([ω]×)R \leftarrow R\,\exp([\boldsymbol{\omega}]_\times) , where the exponential map produces an exactly-orthogonal factor by construction.

Euler View - ML Experiment Monitor