Motivation
The orientation of any object can be represented in a number of ways:
- Euler Angles – Uses 3 angles around independent axis to express the orientation
- Orientation Direction Cosine Matrices – Uses a 3×3 matrix to represent a rotation.
- Quaternion – Uses a 4d vector to reperesent the orientation
Each of the methods have its own merits and demerits. We shall focus here on Quaternions. When using quaternions to describe a rotations, it enjoys the following benifits compared to the other methods:
- It is very easy to see the axis around which the rotation takes places.
- It is easy to interpolate between the two orientation. It does not suffer from Gimbal Lock which the other representations might.
The only downside of this representation is that it might lack intuitiveness. In this system the rotation is give as a single rotation around an axis as compared to a sequence of 3 rotations in the case of other two methods
History
Quaternions were developed by Willain Rowan Hamilton in 1843. His interests around that time was in complex analysis. The subject had not yet developed as a completly and thus his discovery back then was a major step. His liked the idea that complex number can be rotated in a plane by multiplying with another complex number. He was interested in doing the same things with vectors in space.
Purely speaking mathematically, his contribution was in “Field Extension of the complex field \(\mathbb{C}\) to 4 dimensional space of quaternions represented by \(\mathbb{H}\).” As this field is not Abelian, that is, it does not have the properties of being commutative, Hamilton received a lot of backlash. Studying such mathematical structures was considered not very useful those days. But in the current times it is no longer the case. A lot of non abelian groups like matrices are of very large importance.
His contributions had a large impact on the mathematical community. As the American mathematician Howard Eves described the significance of Hamilton’s new approach by saying that
[!quote]
it opened the floodgates of modern abstract algebra. By weakening or deleting various postulates of common algebra, or by replacing one of more of the postulates by others, which are consistent with the remaining postulates, an enormous variety of systems can be studied. As some of these systems we have groupoids, quasigroups, loops, semi-groups, monoids, groups, rings, integral domains, lattices, division rings, Boolean rings, Boolean algebras, fields, vector spaces, Jordan algebras, and Lie algebras, the last two being examples of non-associative algebras.
Quaternions also picked up interest in the computer science and graphics community due to its ease of representing rotations. It also has applications in Quantum physics as the spin states can be represented by Quaternions.
Quaternion Basics
Quaternions is an extension of the 2D complex numbers to 3d. It was invented by Willain Rowan Hamilton in 1843. He was attempting to come up with a technique for multiplying triplets when he arrived at the quaternions. Just as rotations can easily be represented as multiplications with two complex numbers in 2D, quaternions make rotations in 3D easy to compute.
Quaternions are represented as a vector of 4 elements in \(R^4\)
$$
\begin{bmatrix}
a \\
b \\
c \\
d \\
\end{bmatrix} \epsilon R^4
$$
This is also broken down into scalar and vector parts
a = scalar
(b,c,d) = vector
This is also represented as $$q =j\alpha_1 + i\alpha_2 + j\alpha_3 + k\alpha_4$$
The Quaternions are governed by the following rules for multiplication
[!important]
$$
i^2 = j^2 = k^2 = ijk = -1
$$
Addition
Addition in quaternion is same like addition in the case of complex numbers where the numbers are added element wise.
Two quaternions given by
$$
q_1 = a + b\hat{i} + c\hat{j} + d\hat{k}$$ and
$$ q_2 = e + f\hat{i} + g\hat{j} + h\hat{k}$$
gives a resultant sum
[!note]
$$
q_1 + q_2 = (a + e) + (b + f)\hat{i} + (c+g)\hat{j} + (d+h)\hat{k}
$$
Multiplication
The multiplication table is given as
i | j | k | |
---|---|---|---|
i | -1 | k | -j |
j | -k | -1 | i |
k | j | -i | -1 |
Using these rules the two quaternions \(q_1\) and \(q_2\) given by
$$
q_1 = a + b\hat{i} + c\hat{j} + d\hat{k}$$ and
$$ q_2 = e + f\hat{i} + g\hat{j} + h\hat{k}$$
when mulplied using the distributive rule and applyting the multiplication table gives
$$
q_1 q_2 = (ae – bf – cg – dh) + \hat{i}(af + be + ch – dg) + \hat{j}(ag-bh+ce+df) + \hat{k}(ah+bg-cf+de)
$$
The other way of looking at this multiplication when viewed as scalar and vector combination is given as
$$
q_1 = (s_1, \vec{v_1})$$ and
$$ q_2 = (s_2, \vec{v_2})$$
where
$$
s1 = a, s2 = e, \vec{v_1} = (b,c,d), \vec{v2} = (f,g,h)
$$
hence the product is given as
[!note]
$$
q_1q_2 = (s_1s_2 – \vec{v_1}.\vec{v2}, s_1\vec{v_2} + s_2\vec{v_1}+\vec{v_1}\times\vec{v_2})
$$
Conjugation
Conjugation is the same as conjugation in the case of the complex numbers except that all the components are inverted in sign
[!note]
$$
\overline{q_1} = a – b\hat{i} – c\hat{j} – d\hat{k}
$$
Magnitude
Magnitude of a quaternion is given as the square root of sum of square of each element
[!note]
$$
|{q}| = \sqrt{a^2 + b ^ 2 + c^2 +d^2}
$$
Inverse
Inverse is given as conujugate divided by the square of the magnitude
[!note]
$$
q^{-1}=\frac{\overline{q}}{|q|^2}
$$
Rotating a vector
Theorem
[!important]
For any unit quaternion
$$
q = q_0 + \vec{q} = cos\frac{\theta}{2} + \vec{u}sin\frac{\theta}{2} \tag{1}
$$
and for any vector $\vec{v}\;\epsilon\;\mathbb{R}^3$ the action of the operator
$$
L_q(\vec{v}) = q\vec{v}q^*
$$
on $\vec{v}$ is equivalent to a rotation of the vector through an angle $\theta$ about $\vec{u}$ as the axis of rotation.
Why is this theorem important
If we have a vector $\latex vec{v}$ which we desire to rotate by \(\theta\) around the axis \(\vec{u}\) then it can be accomplished easily by forming the quaternion q and multiplying with \(\vec{v}\).
Idea of Proof
Consider a vector \(\vec{v}\). If \(L_q(\vec{v})\) is the rotation operator by the quaternion q on \(\vec{v}\), where the quaternion is given by Equation (1) above. The \(\vec{v}\) can be split into two components.
- One along the axis of \(\vec{u}\), called \(\vec{a}\)
- Another perpendicular to \(\vec{u}\), called \(\vec{n}\)
The proof works by proving that the operator \(L_q\) has no effect on \(\vec{a}\) but rotates \(\vec{n}\) in the plane perpendicular to \(\vec{u}\) by an angle \(\theta\).
Then using the result that the operation \(L_q\) is linear over \(\mathbb{R}^3\) we can say that
$$
L_q(\vec{v}) = L_q(\vec{a}) + L_q(\vec{n})
$$
Hence, rotates \(\vec{v}\) by an angle \(\theta\).
Summary of Proof
- Prove that \(L_q\) is linear over \(\mathbb{R}^3\).
- Prove that \(L_q\) has no effect over \(\vec{a}\)
- Prove that \(L_q\) rotates \(\vec{n}\) by an angle \(\theta\) in a plane perpendicular to \(\vec{u}\).
Proof
Proof for Prove that \(L_q\) is linear over \(\mathbb{R}^3\).
Let \(\vec{v_1},\vec{v_2}\; \epsilon\; \mathbb{R}^3\)
$$
\begin{aligned}
L_q(a_1\vec{v_1} + a_2\vec{v_2})&= q(a_1\vec{v_1} + a_2\vec{v_2})q^*\\
&=(qa_1\vec{v_1} + qa_2\vec{v_2})q^*\\
&=qa_1\vec{v_1}q^*+ qa_2\vec{v_2}q^*\\
&=a_1\;q\vec{v_1}q^*+ a_2\;q\vec{v_2}q^*\\
&= a_1L_q(\vec{v_1}) + a_2L_q(\vec{v_2})
\end{aligned}
$$
Proof for Prove that \(L_q\) has no effect over \(\vec{a}\)
Since \(\vec{a}\) is in the direction of \(\vec{q}\)
$$
\vec{a} = k\vec{q}
$$
Thus
$$
\begin{aligned}
q\vec{a}q^* &= q(k\vec{q})q\\
&= (q_0^2 – ||\vec{q}||^2)k\vec{q} + 2(\vec{q}.k\vec{q})\vec{q}+2q_0(\vec{q}\times\vec{kq})\\
&=q_0^2k\vec{q} – k||\vec{q}||^2\vec{q} + 2k||\vec{q}||^2\vec{q}\\
&= k(q_0^2+||\vec{q}||^2)\vec{q}\\
&=k\vec{q}
\end{aligned}
$$
Here the last reduction happened due to unit quaternion.
Also,
$$
\begin{aligned}
||L_q(\vec{v})|| &= ||q\vec{v}q^*||\\
&=|q|.||\vec{v}||.|q^*|\\
&= ||\vec{v}||
\end{aligned}
$$
Proof that \(L_q\) rotates \(\vec{n}\) by an angle \(\theta\) in a plane perpendicular to \(\vec{u}\).
$$
\begin{aligned}
||L_q(\vec{n})|| &= (q_0^2 – ||\vec{q}||^2)\vec{n} + 2(\vec{q}.\vec{n})\vec{q}+2q_0(\vec{q}\times\vec{n})\\
&= (q_0^2 – ||\vec{q}||^2)\vec{n} +2q_0(\vec{q}\times\vec{n})\\
&=(q_0^2 – ||\vec{q}||^2)\vec{n} +2q_0||q||(\vec{u}\times\vec{n})\\
\end{aligned}
$$
Let us denote \(\vec{u}\times\vec{n} = \vec{n}_\perp\).
Thus
$$
\begin{aligned}
||L_q(\vec{n})|| &=(q_0^2 – ||\vec{q}||^2)\vec{n} +2q_0||q||\vec{n}_\perp\\
&= (cos^2\frac{\theta}{2} – sin^2\frac{\theta}{2}) \vec{n} + 2cos\frac{\theta}{2}sin\frac{\theta}{2}\vec{n}_\perp\\
&= cos\theta\vec{n}+sin\theta\vec{n}_\perp
\end{aligned} \tag{2}
$$
Also note
$$
||\vec{n}_\perp|| = ||\vec{u}\times\vec{n}|| = ||\vec{u}||\;||\vec{n}||sin\frac{\pi}{2}=||n||
$$
From 2, \(L_q(\vec{n})\) rotates \(\vec{n}\) through \(\theta\).
Rotating the reference Coordinate frame
Theorem
For any unit quaternion
$$
q = q_0 + \vec{q} = cos\frac{\theta}{2}+\vec{u}sin\frac{\theta}{2}$$
and for any vector \(\vec{v}\;\epsilon\;\mathbb{R}^3\) the action of the operator
$$ L_{q^*}(\vec{v}) = q^*\vec{v}(q^*)^*= q^*\vec{v}q $$
is a rotation of the coordiante frame about the axis \(\vec{u}\) through an angle \(\theta\) while \(\vec{v}\) is not rotated.
Composition of Rotation
If p and q are 2 unit quaternion. If we first apply \(L_p\) to \(\vec{u}\) and obtain \(\vec{v}\). If then apply \(L_q\) to \(\vec{v}\) to get \(\vec{w}\). The we can compose \(L_q \circ L_p\) to get equivalent single operation
Proof
$$
\begin{aligned}
\vec{w} &= q\vec{v}q*\\
&= qp\vec{u}p^*q^*\\
&= (qp)\vec{u}(qp)^*\\
&= L_{qp}(\vec{u})
\end{aligned}
$$
Composition of Rotation of frame of reference
If p and q are 2 unit quaternion. If we first apply \(L_{p^*}(\vec{u})\) followed by \(L_{q^*}(\vec{v})\) in order to rotate the reference frame first wrt \(p\) and then wrt to \(q\) without moving \(\vec{u}\) and \(\vec{v}\). Then we can compose to get equiviatent single operation \(L_{(pq)^*}\;\). Notice that in the Vector case it was qp and now it is pq.
References
[1] A. Buchmann, “A Brief History of Quaternions and the Theory of Holomorphic Functions of Quaternionic Variables”.
[2] “Attitude Representations – Understanding Direct Cosine Matrices, Euler Angles and Quaternions – Steven Dumble | PhD.” https://stevendumble.com/attitude-representations-understanding-direct-cosine-matrices-euler-angles-and-quaternions/ (accessed Mar. 12, 2023).
[3] Computing Euler Angles: Tracking Attitude Using Quaternions, (Apr. 12, 2020). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=98Mfe-Vfgo0
[4] Euler (gimbal lock) Explained, (Jan. 14, 2009). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=zc8b2Jo7mno
[5] How quaternions produce 3D rotation, (Jul. 30, 2020). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=jTgdKoQv738
[6] Quaternions and 3d rotation, explained interactively, (Oct. 26, 2018). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=zjMuIxRvygQ
[7] Y.-B. Jia, “Quaternions and Rotations”.
[8] Quaternions EXPLAINED Briefly, (Jun. 19, 2016). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=jlskQDR8-bY
[9] Rotations and quaternions, (May 06, 2019). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=rJqII1FyrdM
Leave a Reply
Only people in my network can comment.