Saturday, 21 February 2009

Quaternions

Quaternions, discovered in 1843 by Hamilton, are the extension of complex numbers to four dimensions. As it turns out, they are very useful in computer graphics and can represent any rotation in 3D space in a compact and computationally cheap form. Another advantage of quaternions is that they avoid gimbal lock as they can describe a rotation in one operation as opposed to Euler angles that combine yaw, pitch and roll in separate operations.

A quaternion can be written as where are all different square roots of -1 such that, The vector is closely related to the axis of rotation and the angle of rotation affects all parts of the quaternion as we shall see below.

A unit quaternion, , can represent a rotation of radians around an axis, , by . To rotate a point or vector, , by this quaternion is, It can be shown that the inverse, , for a unit quaternion, , is actually the conjugate where this is defined as,

The product of two quaternions is determined by the product of the basis elements and the distributive law, The transformation expressed by a unit quaternion can also, and more usefully in computer graphics, be represented by the matrix,

Now that's out of the way it's time for some coding.

0 comments:

Post a Comment