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 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|
Addition (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.
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
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|
Division of Q1 by Q2 is as follows
|Q1||Q1 (2 r2 - Q2)|
The congujate of Q = Q* = r - a i - b j - c k.Polar Coordinates
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.