June 2001

Libraries: quaterion.c and quaterion.h.

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 i^{2} = -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

Where "r" might be considered the real component and "a", "b", "c" real valued. The 4 vector (r,a,b,c) might be considered to be a vector in the 4D quaternion space.

When performing operations on complex numbers whenever one
encounters i^{2} 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:

i^{2} = j^{2} = k^{2} =
-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.

Addition (or subtraction) of two quaternions Q_{1} =
r_{1} + a_{1} i + b_{1} j + c_{1} k and
Q_{2} = r_{2} + a_{2} i + b_{2} j +
c_{2} k is performed as follows.

Multiplication of two quaternions is somewhat involved but
follows directly from the relationships above.

Q_{1} Q_{2} = |
[ r_{1} r_{2} - a_{1}
a_{2} - b_{1} b_{2} - c_{1} c_{2}
] +[ r _{1} a_{2} + a_{1} r_{2} +
b_{1} c_{2} - c_{1} b_{2} ] i +[ r _{1} b_{2} + b_{1} r_{2} + c_{1}
a_{2} - a_{1} c_{2} ] j +[ r _{1}
c_{2} + c_{1} r_{2} + a_{1} b_{2}
- b_{1} a_{2} ] k |

Note that quaternion multiplication is not commutative, that is, Q

The length of a quaternion is the familiar coordinate length in
4 dimensional space.

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} |

Division of Q_{1} by Q_{2} is as follows

Q_{1} |
Q_{1} (2 r_{2} - Q_{2}) | |

-------- | = | ------------------- |

Q_{2} |
|Q_{2}|^{2} |

The congujate of Q = Q^{*} = r - a i - b j - c k.

The equivalent to polar coordinates in quaternion space are

- r = |Q| cos(theta1)

a = |Q| sin(theta1) cos(theta2)

b = |Q| sin(theta1) sin(theta2) cos(theta3)

c = |Q| sin(theta1) sin(theta2) sin(theta3)

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.