Geometry, Physics, Control Theory · Siblings

Euler angles, axis–angle representations, rotation matrices, and unit quaternions are four ways to write down a rotation or the orientation of a rigid body in three-dimensional space. Euler angles use three angles of turns about coordinate axes, which are easy to picture but fail to be unique at gimbal lock. An axis–angle representation uses a unit vector along the axis of the rotation and the angle turned about it, which is easy to picture but composes by no simple formula. A rotation matrix uses a $3 \times 3$ matrix with orthonormal columns, which composes by matrix multiplication but has nine entries for three degrees of freedom. A unit quaternion uses four numbers with one condition, which composes by quaternion multiplication and has no gimbal lock, but each rotation has two unit quaternions, $q$ and $-q$.

Definitions

Euler angles

High school

Consider a rigid object, such as an airplane, and a fixed set of reference directions, such as north, east, and down. The Euler angles of the object are three angles that describe the orientation of the object as three turns, made one after another, each about one axis.

For an airplane, the turns are usually applied in the following order

  1. the yaw (turning the nose left or right)
  2. pitch (tilting the nose up or down)
  3. roll (tilting the wings).
Undergraduate

Consider a rigid body whose orientation is given by a rotation matrix $R$. The Euler angles $(\psi, \theta, \phi)$ of the body, in the $z$-$y$-$x$ convention, are the angles such that

\[R = R_z(\psi) \, R_y(\theta) \, R_x(\phi),\]

where $R_z(\psi)$, $R_y(\theta)$, and $R_x(\phi)$ are the rotations by $\psi$, $\theta$, and $\phi$ about the $z$-, $y$-, and $x$-axes, and $-\pi < \psi \leq \pi$, $-\pi/2 \leq \theta \leq \pi/2$, and $-\pi < \phi \leq \pi$. The angles $\psi$, $\theta$, and $\phi$ are called the yaw, the pitch, and the roll.

Worked examples
Properties
  • Euler angles describe an orientation with three numbers, which is the fewest possible.
  • At a pitch of $\theta = \pm \pi/2$, the yaw and the roll turn about the same axis, so only their sum or difference is determined (gimbal lock). Near gimbal lock, small changes of orientation can need large changes of the yaw and the roll.
  • Composing two rotations given by Euler angles has no simple formula in the angles; the rotation matrices or quaternions are multiplied instead.
Undergraduate

Consider a rotation $R$ of $\reals^3$ about the origin. An axis–angle representation of $R$ is a pair $(\vect{u}, \theta)$ of a unit vector $\vect{u}$ and an angle $\theta$ such that $R$ turns space by $\theta$ about the line through the origin in the direction of $\vect{u}$, counterclockwise when viewed from the tip of $\vect{u}$ (the right-hand rule).

Worked examples
Properties
  • Every rotation of $\reals^3$ has an axis–angle representation, by Euler’s rotation theorem.
  • The pairs $(\vect{u}, \theta)$ and $(-\vect{u}, -\theta)$ represent the same rotation, and so do $(\vect{u}, \theta)$ and $(\vect{u}, \theta + 2\pi)$. For the identity rotation, $\theta = 0$ and every unit vector $\vect{u}$ gives an axis–angle representation.
  • The rotation matrix of the rotation represented by $(\vect{u}, \theta)$ is given by Rodrigues’ formula, \[R = I + (\sin \theta) K + (1 - \cos \theta) K^2,\] where $K$ is the skew-symmetric matrix such that $K \vect{v} = \vect{u} \times \vect{v}$ for every vector $\vect{v}$.
  • The unit quaternions of the rotation represented by $(\vect{u}, \theta)$ are \[q = \pm \left( \cos\frac{\theta}{2} + \sin\frac{\theta}{2} \, (u_1 \mathbf{i} + u_2 \mathbf{j} + u_3 \mathbf{k}) \right).\]
  • The axis–angle representation describes a rotation with four numbers and one condition ($\norm{\vect{u}} = 1$). Composing two rotations given by axis–angle representations has no simple formula in the axes and angles; the rotation matrices or unit quaternions are multiplied instead.

rotation matrix

Undergraduate

A rotation matrix is a real $n \times n$ matrix $R$ such that

\[R\trans R = I \quad \text{and} \quad \det R = 1.\]
Worked examples
Properties
  • The columns of a rotation matrix are orthonormal and form a right-handed basis. When $R$ describes the orientation of a rigid body, its columns are the axes of the body, written in the reference frame.
  • The inverse of a rotation matrix $R$ is its transpose: $R^{-1} = R\trans$.
  • The product of two rotation matrices is a rotation matrix, and it represents doing one rotation after the other. The rotation matrices form the group $\mathrm{SO}(n)$.
  • A $3 \times 3$ rotation matrix has nine entries but describes only three degrees of freedom, because the condition $R\trans R = I$ imposes six equations. After rounding errors, such as in the numerical integration of a rotating body, a computed matrix drifts away from satisfying $R\trans R = I$ and must be corrected.

unit quaternion

Undergraduate

A unit quaternion is a quaternion $q = a + b \, \mathbf{i} + c \, \mathbf{j} + d \, \mathbf{k}$ such that

\[a^2 + b^2 + c^2 + d^2 = 1.\]
Worked examples
Properties
  • The rotation of $\reals^3$ by the angle $\theta$ about the axis in the direction of the unit vector $\vect{u} = (u_1, u_2, u_3)$ is represented by the unit quaternion \[q = \cos\frac{\theta}{2} + \sin\frac{\theta}{2} \, (u_1 \mathbf{i} + u_2 \mathbf{j} + u_3 \mathbf{k}).\] The rotation moves each vector $\vect{v}$, written as the quaternion $v_1 \mathbf{i} + v_2 \mathbf{j} + v_3 \mathbf{k}$, to $q \vect{v} q^{-1}$.
  • The unit quaternions $q$ and $-q$ represent the same rotation, so each rotation is represented by exactly two unit quaternions.
  • The product of two unit quaternions is a unit quaternion, and it represents doing one rotation after the other.
  • A unit quaternion describes a rotation of $\reals^3$ with four numbers and one condition, with no gimbal lock. After rounding errors, a computed quaternion is corrected by dividing it by its norm.

Examples

Each row of an example is how one representation writes the rotation in the example’s title.

The identity rotation of space, which leaves every point where it is

Euler angles Yaw $\psi = 0^\circ$, pitch $\theta = 0^\circ$, roll $\phi = 0^\circ$
The Euler angles of the identity rotation are all $0^\circ$, because no turns are needed.
axis–angle representation Angle $\theta = 0^\circ$, with every unit vector $\vect{u}$
The axis–angle representations of the identity rotation have the angle $\theta = 0^\circ$, and every unit vector $\vect{u}$ is an axis, because turning by $0^\circ$ about every axis leaves every point where it is.
rotation matrix $R = I$
The rotation matrix of the identity rotation is the identity matrix $I$, because $I \vect{v} = \vect{v}$ for every vector $\vect{v}$.
unit quaternion $q = 1$ or $q = -1$
The unit quaternions of the identity rotation are $1$ and $-1$, which are the rotations by $0^\circ$ and by $360^\circ$, because $\cos 0^\circ = 1$ and $\cos 180^\circ = -1$ in $q = \cos(\theta / 2) + \sin(\theta / 2)(u_1 \mathbf{i} + u_2 \mathbf{j} + u_3 \mathbf{k})$.

The rotation of space by $90^\circ$ about the $z$-axis, counterclockwise when viewed from the positive $z$-axis

Euler angles Yaw $\psi = 90^\circ$, pitch $\theta = 0^\circ$, roll $\phi = 0^\circ$
The $z$-$y$-$x$ Euler angles of the rotation by $90^\circ$ about the $z$-axis are a yaw of $90^\circ$ and no pitch or roll, because the yaw is the turn about the $z$-axis.
axis–angle representation $(\vect{u}, \theta) = ((0, 0, 1), 90^\circ)$ or $((0, 0, -1), -90^\circ)$
The axis–angle representations of the rotation by $90^\circ$ about the $z$-axis are the axis $\vect{u} = (0, 0, 1)$ with the angle $90^\circ$, and the opposite axis $(0, 0, -1)$ with the opposite angle $-90^\circ$, because turning clockwise about $-\vect{u}$ is turning counterclockwise about $\vect{u}$.
rotation matrix \[R = \begin{bmatrix} 0 & -1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{bmatrix}\]
The rotation matrix of the rotation by $90^\circ$ about the $z$-axis has the images of the coordinate axes as its columns: the $x$-axis turns to the $y$-axis, the $y$-axis turns to the negative $x$-axis, and the $z$-axis stays fixed.
unit quaternion $q = \pm \frac{\sqrt{2}}{2} (1 + \mathbf{k})$
The unit quaternions of the rotation by $90^\circ$ about the $z$-axis are $\pm(\cos 45^\circ + \mathbf{k} \sin 45^\circ) = \pm \frac{\sqrt{2}}{2}(1 + \mathbf{k})$, using half of the angle and the axis $\mathbf{k}$.

The rotation of space by $90^\circ$ about the $y$-axis, counterclockwise when viewed from the positive $y$-axis

A rotation by $90^\circ$ about the $y$-axis is the gimbal lock of the $z$-$y$-$x$ Euler angles, so only the difference of the yaw and the roll is determined. The axis–angle representation, the rotation matrix, and the unit quaternion of the rotation are as easy to write as for every other rotation.

Euler angles Pitch $\theta = 90^\circ$, with every yaw $\psi$ and roll $\phi$ such that $\phi = \psi$
The $z$-$y$-$x$ Euler angles of the rotation by $90^\circ$ about the $y$-axis have the pitch $\theta = 90^\circ$, but the yaw and the roll are not unique (gimbal lock). With $\theta = 90^\circ$, the product $R_z(\psi) R_y(90^\circ) R_x(\phi)$ depends only on $\phi - \psi$, because the roll axis has been turned onto the yaw axis. So every pair of angles such that $\phi = \psi$, such as $\psi = \phi = 0^\circ$ or $\psi = \phi = 30^\circ$, gives this rotation.
axis–angle representation $(\vect{u}, \theta) = ((0, 1, 0), 90^\circ)$ or $((0, -1, 0), -90^\circ)$
The axis–angle representations of the rotation by $90^\circ$ about the $y$-axis are the axis $\vect{u} = (0, 1, 0)$ with the angle $90^\circ$, and the opposite axis $(0, -1, 0)$ with the opposite angle $-90^\circ$, because turning clockwise about $-\vect{u}$ is turning counterclockwise about $\vect{u}$.
rotation matrix \[R = \begin{bmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ -1 & 0 & 0 \end{bmatrix}\]
The rotation matrix of the rotation by $90^\circ$ about the $y$-axis has the images of the coordinate axes as its columns: the $x$-axis turns to the negative $z$-axis, the $y$-axis stays fixed, and the $z$-axis turns to the $x$-axis.
unit quaternion $q = \pm \frac{\sqrt{2}}{2} (1 + \mathbf{j})$
The unit quaternions of the rotation by $90^\circ$ about the $y$-axis are $\pm(\cos 45^\circ + \mathbf{j} \sin 45^\circ) = \pm \frac{\sqrt{2}}{2}(1 + \mathbf{j})$, using half of the angle and the axis $\mathbf{j}$.

Notes

  • Each representation describes a rotation, and so it also describes an orientation, which is the rotation from a reference frame to the body.
  • Converting between the representations is routine: a unit quaternion $q = a + b \, \mathbf{i} + c \, \mathbf{j} + d \, \mathbf{k}$ gives the rotation matrix

    \[R = \begin{bmatrix} 1 - 2(c^2 + d^2) & 2(bc - ad) & 2(bd + ac) \\ 2(bc + ad) & 1 - 2(b^2 + d^2) & 2(cd - ab) \\ 2(bd - ac) & 2(cd + ab) & 1 - 2(b^2 + c^2) \end{bmatrix}.\]
  • Rodrigues’ formula turns an axis–angle representation $(\vect{u}, \theta)$, where $\vect{u} = (u_1, u_2, u_3)$, into the rotation matrix

    \[R = I + (\sin \theta) K + (1 - \cos \theta) K^2,\]

    where $K$ is the skew-symmetric matrix

    \[K = \begin{bmatrix} 0 & -u_3 & u_2 \\ u_3 & 0 & -u_1 \\ -u_2 & u_1 & 0 \end{bmatrix},\]

    which satisfies $K \vect{v} = \vect{u} \times \vect{v}$ for every vector $\vect{v}$.

  • Spacecraft and drone software usually stores orientations as unit quaternions, and shows them to people as Euler angles.

See also

All distinctions · All definitions · Notation