Quaternions
Define the vector space \(\mathbb H := \mathbb R \times \mathbb R^3\) as the real vector space with basis \(\set{1, \hat i, \hat j, \hat k}\) to be the set of all quaternions, i.e.
Multiplication is associative and is extended bilinearly over \(\mathbb R\). The basis of \(\mathbb H\) satisfies the following multiplicative identities:
From the definition above, we can derive the following (notice the noncommutativity):
This fully defines the quaternions.
Quaternions are usually written in the form of \(p = a+b\hat i+c\hat j + d\hat k\), though they are sometimes also written in a form called scalar-vector notation: \(p = (q_0, \mathbf q)\) where \(q_0 \in\mathbb R\) and \(\mathbf{q}\in\mathbb{R}^3\).
Hamilton Product (Quaternion Multiplication)¶
I now aim to define the product of two arbitrary quaternions.
Let \(p = a + \mathbf{u}\) and \(q = b + \mathbf{v}\), where:
By bilinearity:
Expanding the latter term, we get:
Therefore:
Quaternion Operations¶
Let \(p = a + b\hat i+ c\hat j + d\hat k =(a, \mathbf{v})\) be a quaternion.
Quaternion Conjugate¶
The quaternion conjugate of \(p\) is obtained by negating the vector part
Multiplying a quaternion by its conjugate yields its magnitude squared:
Quaternion Inverse¶
The quaternion inverse of \(p\) satisfies the following identity:
Since \(pp^* = p^*p = \lVert p\rVert^2\), we therefore have that:
Therefore, if \(p\) is unitary, the inverse and the conjugate are equal.
Quaternion Sandwich Product¶
Suppose we have a vector \(\mathbf v \in \mathbb R^3\) that is represented as a pure quaternion \(v = (0, \mathbf{v})\).
Let:
be a unit quaternion, where \(\mathbf{\hat n}\) is the unit vector along the rotation axis, and \(\theta\) is the rotation angle along that axis (following RHR conventions).
We will now show that the sandwich product:
rotates the vector \(\mathbf{v}\) about the rotation axis \(\mathbf{\hat n}\) with an angle of \(\theta\).
Proof: Let \(c = \cos\frac\theta 2\) and \(s=\sin\frac\theta 2\). Then \(\hat q = (c, s\mathbf{\hat n})\). By the Hamilton product
Right-multiplying the above by \(\hat q^{-1} = \hat q^*\), we get that:
Notice that the scalar part of the above is zero, so it is a pure quaternion. Using the identities \(\mathbf{a\times b} = -\mathbf{b \times a}\) and \((\mathbf{a \times b}) \times \mathbf{c} = \mathbf{b}(\mathbf{a \cdot c}) - \mathbf{a}(\mathbf{b\cdot c})\), we get:
Finally, applying the double angle identities, we get that:
We note that this is identically the Rodrigues' rotation formula.
If you are not convinced, let us prove that this indeed does what it says. Take:
Then:
Notice that \(\mathbf{v_\Vert}\) remains unchanged by the operation. If \(\mathbf{v}_\perp \neq 0\), then the unit vectors:
forms a orthonormal basis on the plane perpendicular to \(\mathbf{\hat n}\). A rotation of \(\theta\) on the vector \(\mathbf{v_\perp}\) on this plane looks like:
which is precisely a rotation of \(\theta\) using RHR. Therefore the quaternion sandwich product indeed does rotation.
Q.E.D.
Left-Multiply vs. Right-Multiply¶
Let \(q\) be the rocket’s orientation, mapping body coordinates to world coordinates. For an additional rotation \(\delta q\):
- World-frame rotation: \(q'=\delta q q\) -- rotate in the world frame. Intuition: Rotate about a rocket axis first, then let \(q\) carry that axis into the rocket’s current orientation. So the rotation follows the body axis.
- Body-frame rotation: \(q'=q \delta q\) -- rotate about a body frame. Intuition: Place the rocket in its current orientation first, then rotate it about a fixed world axis.
Here, \(\delta q\) axis is expressed in the corresponding frame.
World → multiply on the left. Body → multiply on the right.
Why Quaternions?¶
We use quaternions because it give you a compact way to represent the rocket’s orientation that stays well behaved as it rotates. Euler angles can be become singular at certain angles (known as Gimbal Lock). If two of the rotation axes align, and the angles stop describing three independent rotational directions. It is possible to choose a convention that avoids it around upright flight, but quaternions avoid orientation singularities altogether. It also makes the math a lot more convenient.