Most students of algebra are familiar with complex numbers, that is, numbers that have two components called real and imaginary that can often be interpreted as 2 dimensions. A complex number is normally written as a + ib where i2 = -1 and a and b are two real values quantities. This idea can be extended to higher dimensions but it turns out that 4 components have useful properties. These are called quaternions and are attributed to Sir William Rowan Hamilton who published a major analysis in 1844 called "On a Species of Imaginary Quantities Connected with a Theory of Quaternions" in the Proceedings of the Royal Irish Academ (2, pp 424-434)
In this discussion we will write a quaternion "Q" as
When performing operations on complex numbers whenever one encounters i2 then one knows that is equal to the simpler -1. There are similar but slightly more complicated relationships between i,j,k in quaternion space. They are as follows:
| i2 = j2 = k2 = -1 | ||
| i j = k | j k = i | k i = j |
| j i = -k | k j = -i | i k = -j |
Note that the order in which i,j,k appears in an expression is important. Also note that there is no linear relationship between i,j,k.
AdditionAddition (or subtraction) of two quaternions Q1 = r1 + a1 i + b1 j + c1 k and Q2 = r2 + a2 i + b2 j + c2 k is performed as follows.
The congujate of Q = Q* = r - a i - b j - c k.
Multiplication
Multiplication of two quaternions is somewhat involved but follows
directly from the relationships above.
| Q1 Q2 = |
[ r1 r2 - a1 a2 -
b1 b2 - c1 c2 ] + [ r1 a2 + a1 r2 + b1 c2 - c1 b2 ] i + [ r1 b2 + b1 r2 + c1 a2 - a1 c2 ] j + [ r1 c2 + c1 r2 + a1 b2 - b1 a2 ] k |
Note that quaternion multiplication is not commutative, that is, Q1 Q2 is NOT the same as Q2 Q1
Length (modulus)The length (magnitude) of a quaternion is the familiar coordinate length in 4 dimensional space.
where Q* is the congujate (see later) which expands to
and
Inverse
The inverse of a quaternion Q-1 such that
Q Q-1 = 1 is given by
| r - a i - b j - c k | |
| Q-1 = | ------------------------ |
| |Q|2 |
The inverse of a normalised quaternion is simply the congujate, otherwise the magnitude of the inverse is 1/|Q|. So the above expression normalises the quaternion and then scales by 1/|Q|.
DivisionDivision of Q1 by Q2 is as follows
| Q1 | Q1 (2 r2 - Q2) | |
| -------- | = | ------------------- |
| Q2 | |Q2|2 |
If m = sqrt(a2 + b2 + c2) and v is the unit vector (a,b,c) / m then the exponential of the quaternion Q is
The equivalent to polar coordinates in quaternion space are
theta1 is known as the amplitude of the quaternion, theta2 and theta3 are the latitude (or co-latitude) and longitude respectively. The representative point of a quaternion is the normalised vector (a,b,c), that is, where (a,b,c) intersects the unit sphere centered at the origin.
Rotation of a vector about another vectorTo rotate a 3D vector "p" by angle theta about a (unit) axis "r" one forms the quaternion
and the rotation quaternion
The rotated vector is the last three components of the quaternion
It is easy to see that rotation in the opposite direction (-theta) can be achieved by reversing the order of the multiplication.
Note also that the quaternian Q2 is of unit magnitude, and needs to be in order to be a valid rotation.
Converting a quaternion to a matrix
Given a quaternion rotation the corresponding 3x3 rotation matrix M is given by
| M = |
|
|
|