3. Chapter 1
Introduction
Quaternions are a Victorian mathematical invention that is used in modern com-
puter gaming applications today. This report provides an overview of quater-
nions, giving a brief history, the theory and describing their uses. The history
section explains how they were discovered and how they were used over the next
170 years. The theory section takes a look at the basic properties and identi-
ties of quaternions. The final section is an exploration of their application in
mathematics, physics and computer graphics.
2
4. Chapter 2
History
When it finally came time for quaternions to enter the world they did so via a
blunted pen knife. In 1843, while walking along the Royal Canal in Dublin, Sir
William Rowan Hamilton suddenly arrived at the concept. He rushed over to
the Broom Bridge and inscribed on it the famous equation:
i2
= k2
= j2
= ijk = 1
Having worked towards this discovery for the past fifteen years, Hamilton had
made a significant step forwards for mathematics at the time.
He was trying to extend the complex numbers in two dimensions to three dimen-
sions. This was known as his theory of triplets. By abandoning commutativity
and adding a fourth dimension Hamilton had managed to find a way round
the theory of triplets and discovered quaternions. Hamilton was already a very
sucessful mathematician. Quaternions were the topic to which he would dedi-
cate the next and last twenty-two years of his life. [5]
While Hamilton is known as the creator and champion of quaternions he was
not the only one at the time to have made steps in this field. Gauss, in papers
unpublished until 1900, showed he had discovered quaternions as early as 1819.
Rodruigues’ work on rotation, published in 1840, was a significant precursor. [1]
Hamilton went on to publish 109 of the 151 papers published on quaternions by
his death in 1865. He was working on his book, Elements of Quaternions, until
a few days before he died. [5]
Quaternions found their way into a scientific context via James Clerk Maxwell
when he used the vector part of quaternions in his Treatise on Electricity and
Magnetism. He was influenced by Peter Guthrie Tait who expressed the theo-
rems of Gauss, Stokes and Green in quaternion notation. [10]
3
5. Following the invention of vector algebra by Josiah Willard Gibbs, quaternions
fell into disuse. Gibbs recognised that it was not necessary to introduce the
imaginary part of quaternions when applying them to the world of physics.
In 1891, in the journal Nature, there was a vigorous and prolonged argument
between Gibbs and Tait with Gibbs preferring the minimalist approach in not
including the imaginary part of quaternions in his vector algebra. Tait, however,
was a staunch supporter of the elegance and notational superiority of quater-
nions and so disagreed with stripping them down for the parts needed in physics.
He commented ’Prof Gibbs must be ranked as one of the retarders of quaternion
progress, in view of his pamphlet on Vector Analysis, a sort of hermaphrodite
monster, compounded of the notations of Hamilton and Grassman.’ [4]
After that, quaternions took a back seat only finding application in specific ar-
eas of physics such as quantum mechanics and quantum field theory. Writing
in 1966, however, Bork predicted ’Perhaps we shall again see a great resurgence
in the quaternion.’ [4]
He was right. Today quaternions have found themselves a new home in comput-
ing. Any video game that requires a player to look around at objects requires a
graphics card to rotate continuously objects in three dimensions for a realistic
experience. The SLERP algorithm, discussed later in this report, uses quater-
nions to speed up graphical output. One hundred and seventy years later we
can still feel the e↵ects of Hamilton’s discovery in 1843.
4
6. Chapter 3
Theory
Hamilton had already showed that complex numbers form an algebra of couples.
He then began exploring the idea of a complex number with two imaginary parts.
This was his Theory of Triplets that he was unable to make work. However when
he discovered quaternions, from the latin quaternio, meaning four, he realised
a third imaginary component was necessary.
This is a quaternion. [8]
w = a + bi + cj + dk
The addition of quaternions is straightforward, simply adding the coe cients of
i,j and k:
w + z = (aw + az) + (bw + bz)i + (cw + cz)j + (dw + dz)k
The method for multiplication is as follows:
w ⇤ z = (awaz bwbz cwcz dwdz)
+(awbz + awbz + cwdz cwdz)i
+(awcz + awcz bwdz + bwdz)j
+(awdz + awdz + bwcz bwcz)
The conjugate of a quaternion is :
¯w = a bi cj dk
5
7. This is the norm.
||w|| =
p
a2 + b2 + c2 + d2
[11]
Identities are
k = ( 1)k = ijk(k) = ij(k2
) = ij( 1) = ij
j = ( 1)j = (ijk)j = ik(j2
) = ik( 1) = ik
i = (1)i = ( ijk)i = (i2
)( jk) = ( 1)( jk) = jk
The Cayley table below, along with these identities shows that multiplication
of quaternions is non-commutative.
Q ⇥ Q 1 -1 i -i j -j k -k
1 1 -1 i -i j -j k -k
-1 -1 1 -i i -j j -k k
i i -i -1 1 k -k -j j
-i -i i 1 1 -k k j -j
j j -j -k k 1 1 i -i
-j -j j k -k 1 1 -i i
k k -k j -j -i i 1 1
-k -k k -j j i -i 1 1
Table 3.1: Cayley Table
6
8. Chapter 4
Applications
4.1 Group Theory and Number Theory
In group theory, a group is a set combined with a binary operation for which
four ’group axioms’ apply. The set of quaternions is a subgroup of order 8,
defined as {±1, ±i, ±j, ±k}. A ring is a set combined with 2 binary operations,
for which 8 ’ring axioms’ apply. Hurwitz introduced the ring of integral quater-
nions [6], which is a subring of H. H is the set of all quaternions, labelled H
after Hamilton, where for a+bi+cj +dk, either each of a, b, c, d, 2 Z, or each of
a, b, c, d is congruent to modulo Z. This was used to prove Lagrange’s theorem,
that every positive integer is the sum of at most 4 squares. [6]
4.2 Applications in Physics
In physics, the Dirac equation is a wave equation that was derived by British
physicist Paul Dirac in 1928. Objects related to quaternions arise from the
solution of this equation in particle physics. The non-commutativity of quater-
nions is essential here. The Lorentz Transforms are coordinate transformations
between two coordinate frames that move at constant velocity relative to each
other. Quaternions can be used to express this, making them useful for work
on special and general relativity. Quaternion properties in rotations make them
useful in scattering experiments in crystallography, used to determine the ar-
rangement of atoms in crystalline solids. [6] [13]
4.3 Heisenberg Uncertainty Principle
Quaternions can be used in the Heisenberg Uncertainty Principle. This is refers
to any variety of mathematical inequalities, in which certain pairs of physical
7
9. properties of a particle can be known. [7] These pairs are known as complimen-
tary variables. The principle was introduced by the German physicist Werner
Heisenberg in 1927. It states that the more precisely measured one aspect of
the complimentary variables is, the less precisely the other is determined, and
vice versa. For example, if we know a particle’s position and momentum, then
the more precisely the position, the less precisely the momentum is known. In
the case of quaternions, the Uncertainty Principle states that PQ QP = h,
where P and Q are linear operators that represent momentum and position
respectively, and h is Planck’s constant, which is non-zero. [13] This is only
possible because quaternions are non-commutative. If they were commutative,
then PQ QP would be equal to zero.
4.4 3-D Animation And Linear Interpolation
A significant application of quaternions is their use in computer programming.
In particular, they have made an impact in three-dimensional (3D) animation
due to their usefulness in storing and manipulating rotations and orientations
in 3D space. Euler angles may appear suited to this purpose, being three-
dimensional vectors whose entries are either x, y and z coordinates for orien-
tations or the rotation about the x, y and z axis for rotations. However, this
approach poses problems, specifically their proneness to gimbal locking [2] and
their lack of suitability to linear interpolation between orientations.
If Euler angles are used to express certain rotations, when a single axis is rotated
by 90 degrees, say the y-axis, the x- and z-axes are forced into a parallel config-
uration, resulting in a loss of one degree of freedom. This is what is meant by
gimbal locking (see figure 4.1). In particular, it is an issue most problematic in
three-dimensional computer game design where it can restrict the player’s move-
ment to a two-dimensional plane. It can also be inconvenient in animation. [3]
One solution to this issue is the introduction of an additional degree of freedom;
or equivalently, raising the system from three to four dimensions by using a
vector representation of quaternions. Once this is done, if two axes are forced
into a parallel configuration, the system still maintains three degrees of freedom.
With regards to linear interpolation between orientations, quaternions are again
a good solution. This kind of interpolation in 3D graphics refers to an algorithm
which takes two three-dimensional positions as inputs and results in a smoothly
animated rotation between them. Finding and animating a smooth path from
one point to another with Euler angles is considerably less e cient than it is
with quaternions. Cheap Euler angle-based interpolation algorithms result in
non-optimal paths to the final destination and even if more e cient algorithms
are used, the system can still become gimbal locked, resulting in a path which
is also sub-optimal as the object must move in various directions to free itself of
gimbal lock, resulting in seemingly erratic movement. In comparison, interpolat-
8
10. Figure 4.1: A 3 dimensional gimbal in its default state (left) and a gimbal locked
state (right). [12]
ing between quaternion orientations is much more e cient with a comparatively
cheap formula known as Spherical Linear Interpolation (SLERP). SLERP refers
to the the linear interpolation between two points along the surface of a sphere,
rather than as a direct line through three-dimensional space. The reason we
are interested in this is that, much like the set of two-dimensional unit vectors
makes up the edge of a two-dimensional unit circle, the set of four-dimensional
unit quaternions makes up the surface of a four-dimensional unit hypersphere.
Visualising this is di cult, but that does not matter too much as spherical in-
terpolation in four dimensions works just as it does in three.
Let A, B be points on a sphere and let 0 u 1. Then, where ⌦ is the angle
subtended by the arc between A and B,
SLERP(A, B, u) = A
sin(1 u)⌦
sin(⌦)
+ B
sin(⌦u)
sinh(⌦)
[9]
Using u as a parameter to determine how far along the arc we want to be, u = 0
being our start point, A, and u = 1 being our end point, B, we can generate
frames of the animation to match the frame rate of the video or game being
played by incrementally increasing u. This results in perfectly smooth motion.
So, when considering 3D animation, we can take a pure quaternion A (a quater-
nion of the form 0+xi+yj +zk, this being equivalent to the three-dimensional
vector (x,y,z)) and a pure quaternion B and, using SLERP, linearly interpolate
between the two points producing pure quaternions at each step of the way. In
this way, the result will always be equivalent to a three-dimensional position.
9
11. While it may seem counterintuitive to apply the four-dimensional quaternions
to a problem occurring strictly in three dimensions, these methods have simpli-
fied animation considerably and advanced the field of computer graphics.
10
12. Bibliography
[1] S Altmann. Mathematics Magazine, 62:p291–308, 1989.
[2] P Banerjee and D Zetu. Virtual Machine. John Wiley and Sons, Inc., 2001.
[3] N Bobic. Rotating objects using quaternions.
http://www.gamasutra.com/view/feature/131686/rotating objects using quaternions.php,
1998. Last accessed 2nd November 2016.
[4] A Bork. Vectors versus quaternions - the letters in nature. American
Journal of Physics, 34:p202, 1966.
[5] M Crowe. A History of Vector Analysis. Dover Publications, Inc., 1987.
[6] R Eimerl. The Quaternions and their Applications. University of Puget
Sound, 2015.
[7] A Jha. What is heisenberg’s uncertainty principle?
https://www.theguardian.com/science/2013/nov/10/what-is-heisenbergs-
uncertainty-principle, 2013. Last accessed 1st November 2016.
[8] P Kelland and P. G. Tait. Introduction to Quaternions with Numerous
Examples. Macmillan and co., 1873.
[9] K Shoemake. Development of vector analysis from quaternions. SIG-
GRAPH ’85 Proceedings of the 12th annual conference on Computer graph-
ics and interactive techniques, pages p245–254, 1985.
[10] R Stephenson. Development of vector analysis from quaternions. American
Journal of Physics, 34:p194, 1966.
[11] E.W. Weisstein. Quaternion. http://mathworld.wolfram.com/Quaternion.html,
2004. Last accessed 1st November 2016.
[12] Wikipedia. Gimbal lock. https://en.wikipedia.org/wiki/Gimbal lock, 2016.
Last accessed 2nd November 2016.
[13] Zipcon. Applications of quaternions.
http://www.zipcon.net/ swhite/docs/math/quaternions/applications.html,
2010. Last accessed 1st November 2016.
11