Quaternions

Quaternions define a 4 dimensional algebra which is particularly useful for dealing with rotations in 3d. They are often used when you might want to produce a smooth rotation by interpolating between two orientations. Common applications are 3d graphics animation (e.g. games or CGI) and robotic kinematics.

Quaternions can be thought of as being similar to complex numbers but with 3 imaginary components instead of just one. These components are labelled ii, jj, kk and are all square roots of -1.

Quaternions were discovered by William Hamilton in 1843. His moment of inspiration is encapsulated by the following equation (which he famously etched onto Brougham Bridge in Dublin):

i2=j2=k2=ijk=1.i^2=j^2=k^2=ijk=-1.

The quaternion number system is a superset of the complex numbers.

Operations

A quaterion qq can be represented by four numbers a,b,c,da,b,c,d as follows:

q=a+bi+cj+dk.q=a+bi+cj+dk.

Suppose we have two quaternions:

q1=a1+b1i+c1j+d1kq_1=a_1+b_1i + c_1j +d_1k
q2=a2+b2i+c2j+d2kq_2=a_2+b_2i + c_2j +d_2k

The sum of two quaternions is calculated as follows:
q1+q2=(a1+a2)+(b1+b2)i+(c1+c2)j+(d1+d2)kq_1+q_2 = (a_1+a_2) + (b_1+b_2)i + (c_1+c_2)j +(d_1+d_2)k

The following table describes the relationships between i,j,ki,j,k under multiplication:

i.i=1        i.j=k        i.k=jj.i=k        j.j=1        j.k=ik.i=j         k.j=i        k.k=1\begin{matrix} i.i&=&-1 & \;\;\;\; i.j&=&k & \;\;\;\; i.k&=&-j\\ j.i&=&-k & \;\;\;\; j.j&=&-1 & \;\;\;\; j.k&=&i\\ k.i&=&j & \;\;\;\;\ k.j&=&-i & \;\;\;\; k.k&=&-1 \end{matrix}
As can be seen from this table, multiplication is non-commutative (in contrast with complex numbers).

Unit quaternions

The norm (or magnitude) of a quaterion is given by:
a2+b2+c2+d2\sqrt{a^2+b^2+c^2+d^2}

A quaternion with unit norm is a versor. In robotics, a unit quaternion may be described as an attitude quaternion.

Conjugate

The conjugate of quaternion qq is written as:
q=abicjdk.q^* = a-bi-cj-dk.
The product qqqq^* is always a real number and has the value:
qq=a2+b2+c2+d2.qq^* = a^2+b^2+c^2+d^2.
If qq is a unit quaternion, its inverse q1q^{-1} is qq^*.