website articles
thinking with quaternions - 2006
I am not going to explain how quaternion can be used to ratate 3D vectors. Instead, the aim of this article is to summarize and share a few useful ideas about quaternions in some projects:

Let q be a quaternion. As we know, a quaternion has one real component and three imaginary component. The three imaginary units i, j and k fullfill i2=-1, j2=-1 and k2=-1, as usual. However, what we are interested in for 3D graphics is in the axis/angle notation of the quaternion. By packing together the three imaginary components we can think on the quaternion as a real value w plus a 3D vector v = { x, y, z }:

q = { w, x, y, z } = { w, v } = w + x⋅i + y⋅j + z⋅k

To get our axis/angle notation we just have to impose to our quaternion that the real component w is the cosine of a given half-angle and the vector v to be a normalized vector a scaled by the sine of that same half-angle.

q = { cos(ω/2), a⋅ sin(ω/2) }

Such a quaternion following the last restriction can be checked to be normalized, since by the definition of norm/modulus of a quaternion

|q|2 = w2 + x2 + y2 + z2

we have that

|q|2 = cos2(ω/2) + (x2 + y2 + z2)⋅sin2(ω/2)

so

|v|2 = 1 → |q|2 = cos2(ω/2) + sin2(ω/2) = 1


Now, the interesting property comes into the game. The exponentiation of quaternions happens to be like this

qt = { cos(ω/2), a⋅ sin(ω/2) }t = { cos(ω⋅t/2), a⋅ sin(ω⋅t/2) }

What results in the following interpretation: self-multiplying a quaternion t times is the same as multiplying the angle by t (even if I find this interpretation a bit tricky for non integer values of t...).

We can now start to see why quaternions are used for angular operations. Actually, we know a normalized quaternion represents a 3D rotation around the axis a by an angle of ω. And we know that concatenating two rotations can be done by multiplying the two corresponding quaternions. Hence what we have to remember is just the first two rows of the following table:


Angular SpaceQuaternion Space
Addα + βqα ⋅ qβ
Scaleα ⋅ tqαt
Madα + β ⋅ tqα ⋅ qβt
Lerpα ⋅ t + β ⋅ (1-t)qαt ⋅ qβ1-t


We can now easily convert any angular operation that we want to perform into the correct quaternion operations. Just replace additions/subtractions by multiplications/divisions, and multiplications/divisions by powers/roots, and we are done.

This relationship between angle and quaternion operations quite resembles the relationship between linear and logarithmical operations (say, Laplace Transform)... Actually, there is a reason for this, and it is that quaternions are a generalization of complex numbers, and as such normalized quaternions are generalization of pure complex exponentials and thus the logarithmic relationships come apparent. Actually, if we have the following normalized quaternion

qω,a = cos(ω/2) + a⋅ sin(ω/2)

and we make the axis equal to the real axis a=(1,0,0), we have

qω,(1,0,0) = cos(ω/2) + i⋅ sin(ω/2) = ei⋅ ω/2

which is your traditional complex number rotor.