Quaternions

A singularity-free, 4-parameter attitude representation widely used in spacecraft GNC.

1.3 Quaternions (Euler Parameters)

Quaternions (also called Euler parameters) provide a compact and globally nonsingular way of representing orientation. Unlike Euler angles, they do not suffer from gimbal lock, and unlike rotation matrices, they avoid redundancy. They are the industry standard for spacecraft, UAVs, and robotics.

1.3.1 Quaternion Representation

A quaternion contains a scalar part and a vector part:

\[ \boldsymbol\beta = \begin{bmatrix} \beta_0 \\[4pt] \boldsymbol\varepsilon \end{bmatrix} = \begin{bmatrix} \beta_0 \\[2pt] \beta_1 \\[2pt] \beta_2 \\[2pt] \beta_3 \end{bmatrix}. \]

It corresponds to an axis–angle rotation with

\[ \phi = \text{rotation angle}, \qquad \mathbf e = \begin{bmatrix} e_1 \\ e_2 \\ e_3 \end{bmatrix} \text{ (unit rotation axis)}, \] \[ \beta_0 = \cos\frac{\phi}{2}, \qquad \boldsymbol\varepsilon = \mathbf e \,\sin\frac{\phi}{2}. \]

Unit constraint

Quaternions satisfy the unit–norm condition \[ \beta_0^2 + \beta_1^2 + \beta_2^2 + \beta_3^2 = 1, \] so \(\boldsymbol\beta\) lies on the unit 4-sphere \(S^3 \subset \mathbb R^4\).

1.3.2 Quaternion Algebra

A. Quaternion product

For two rotations represented by \(\boldsymbol\beta' = (\beta_0', \boldsymbol\varepsilon')\) and \(\boldsymbol\beta'' = (\beta_0'', \boldsymbol\varepsilon'')\), the combined rotation is \(\boldsymbol\beta = \boldsymbol\beta' \otimes \boldsymbol\beta''\) with

\[ \begin{aligned} \beta_0 &= \beta_0' \beta_0'' - \boldsymbol\varepsilon'^{\!T}\boldsymbol\varepsilon'',\\[4pt] \boldsymbol\varepsilon &= \beta_0' \boldsymbol\varepsilon'' + \beta_0'' \boldsymbol\varepsilon' + \boldsymbol\varepsilon' \times \boldsymbol\varepsilon''. \end{aligned} \]

This is the key to chaining rotations—clean, nonsingular, and bilinear.

B. Matrix form of quaternion multiplication

The same product can be written with a \(4\times4\) left-multiplication matrix \(G(\boldsymbol\beta')\):

\[ \boldsymbol\beta = G(\boldsymbol\beta')\,\boldsymbol\beta'', \] \[ G(\boldsymbol\beta') = \begin{bmatrix} \beta_0' & -\beta_1' & -\beta_2' & -\beta_3' \\ \beta_1' & \beta_0' & -\beta_3' & \beta_2' \\ \beta_2' & \beta_3' & \beta_0' & -\beta_1' \\ \beta_3' & -\beta_2' & \beta_1' & \beta_0' \end{bmatrix}. \]

A similar right-multiplication matrix \(H(\boldsymbol\beta'')\) satisfies \(\boldsymbol\beta = H(\boldsymbol\beta'')\,\boldsymbol\beta'\). For unit quaternions these matrices are orthogonal, so the rotation magnitude is preserved. This provides a simple bilinear method to combine rotations—far cleaner than Euler angles.

1.3.3 Quaternion–DCM Conversion

A. Quaternion → DCM

For a unit quaternion \((\beta_0,\beta_1,\beta_2,\beta_3)\), the corresponding Direction Cosine Matrix \(C(\boldsymbol\beta)\) is

\[ C(\boldsymbol\beta) = \begin{bmatrix} \beta_0^2 + \beta_1^2 - \beta_2^2 - \beta_3^2 & 2(\beta_1\beta_2 + \beta_0\beta_3) & 2(\beta_1\beta_3 - \beta_0\beta_2) \\[4pt] 2(\beta_1\beta_2 - \beta_0\beta_3) & \beta_0^2 - \beta_1^2 + \beta_2^2 - \beta_3^2 & 2(\beta_2\beta_3 + \beta_0\beta_1) \\[4pt] 2(\beta_1\beta_3 + \beta_0\beta_2) & 2(\beta_2\beta_3 - \beta_0\beta_1) & \beta_0^2 - \beta_1^2 - \beta_2^2 + \beta_3^2 \end{bmatrix}. \]

B. DCM → Quaternion (Shepperd algorithm)

A robust, nonsingular way to recover a quaternion from a DCM \(C\) is:

\[ \begin{aligned} \beta_0^2 &= \frac{1 + \operatorname{tr}(C)}{4},\\ \beta_1^2 &= \frac{1 + 2C_{11} - \operatorname{tr}(C)}{4},\\ \beta_2^2 &= \frac{1 + 2C_{22} - \operatorname{tr}(C)}{4},\\ \beta_3^2 &= \frac{1 + 2C_{33} - \operatorname{tr}(C)}{4}. \end{aligned} \]

Choose the largest of these four values, take its square root to fix the corresponding \(\beta_i\), and obtain the remaining components from

\[ \begin{aligned} \beta_0\beta_1 &= \tfrac14(C_{23} - C_{32}),\\ \beta_0\beta_2 &= \tfrac14(C_{31} - C_{13}),\\ \beta_0\beta_3 &= \tfrac14(C_{12} - C_{21}), \end{aligned} \]

and the cyclic permutations. This strategy avoids division by very small numbers and is numerically stable.

1.3.4 Quaternion Kinematics

For body angular velocity in the body frame \(\boldsymbol\omega = [\,\omega_1,\ \omega_2,\ \omega_3\,]^T\), the quaternion kinematics are

\[ \dot{\boldsymbol\beta} = \frac12\,B(\boldsymbol\beta)\,\boldsymbol\omega, \] where the \(4\times3\) matrix \(B(\boldsymbol\beta)\) is \[ B(\boldsymbol\beta) = \begin{bmatrix} -\beta_1 & -\beta_2 & -\beta_3 \\ \beta_0 & -\beta_3 & \beta_2 \\ \beta_3 & \beta_0 & -\beta_1 \\ -\beta_2 & \beta_1 & \beta_0 \end{bmatrix}. \]

Expanded component–wise

\[ \begin{aligned} \dot\beta_0 &= -\tfrac12(\beta_1\omega_1 + \beta_2\omega_2 + \beta_3\omega_3),\\[4pt] \dot\beta_1 &= \tfrac12(\beta_0\omega_1 + \beta_2\omega_3 - \beta_3\omega_2),\\[4pt] \dot\beta_2 &= \tfrac12(\beta_0\omega_2 - \beta_1\omega_3 + \beta_3\omega_1),\\[4pt] \dot\beta_3 &= \tfrac12(\beta_0\omega_3 + \beta_1\omega_2 - \beta_2\omega_1). \end{aligned} \]

These equations are always defined (no singularity). If \(\boldsymbol\omega(t)\) is known, the dynamics are linear in the state \(\boldsymbol\beta\); if \(\boldsymbol\omega\) is also a state, the system is bilinear.

1.3.5 Scalar–Vector Split (\(\beta_0\) and \(\boldsymbol\varepsilon\))

Define the vector part \(\boldsymbol\varepsilon = (\beta_1,\beta_2,\beta_3)^T\). The kinematics can be written compactly as

\[ \begin{aligned} \dot\beta_0 &= -\tfrac12\,\boldsymbol\varepsilon^T\boldsymbol\omega,\\[4pt] \dot{\boldsymbol\varepsilon} &= \tfrac12\bigl(\beta_0 I_{3} + [\boldsymbol\varepsilon]_\times\bigr) \boldsymbol\omega, \end{aligned} \]

where \([\boldsymbol\varepsilon]_\times\) is the \(3\times3\) skew-symmetric matrix associated with \(\boldsymbol\varepsilon\). In this form, \(\boldsymbol\varepsilon\) points along the rotation axis and \(\beta_0\) controls the overall rotation magnitude.

1.3.6 Normalization & Numerical Care

Ideally a unit quaternion satisfies \(\|\boldsymbol\beta\| = 1\) at all times, but numerical integration introduces drift so that \(\|\boldsymbol\beta\| \neq 1\). After each integration step, simply renormalise:

\[ \boldsymbol\beta \leftarrow \dfrac{\boldsymbol\beta}{\|\boldsymbol\beta\|}. \]

Enforcing this single scalar condition is much easier than re-orthonormalising a full DCM.

1.3.7 Advantages of Quaternions

Major advantages

Disadvantages

1.3.8 Physical Interpretation

A unit quaternion corresponds to a point on the 4-D unit sphere. A rigid body’s attitude evolves along a geodesic on this sphere. The pair \(\pm\boldsymbol\beta\) describes the same physical orientation, and all rotation operators depend only on products of \(\beta_i\), so the overall sign has no physical effect.

1.3.9 Composite Rotations & Practical Use

For two successive rotations represented by \(\boldsymbol\beta_1\) and \(\boldsymbol\beta_2\), the overall attitude is

\[ \boldsymbol\beta_{\text{final}} = \boldsymbol\beta_2 \otimes \boldsymbol\beta_1. \]

This avoids the transcendental, singular, and ill-conditioned expressions that appear when chaining Euler angles. For this reason, almost all spacecraft attitude filters (EKF/UKF), star trackers, and flight software operate internally with quaternions.

1.3.10 Summary

Quaternions provide a clean, globally valid, and numerically stable attitude representation. They unify the axis–angle picture with the group properties of \(SO(3)\) and form the backbone of modern GNC systems.