Quaternion math routines
Quaternions are an alternate way to represent the rotation part of a
transformation, and can be easier to manipulate than matrices. As with a
matrix, you can encode a geometric transformations in one, concatenate
several of them to merge multiple transformations, and apply them to a
vector, but they can only store pure rotations. The big advantage is that
you can accurately interpolate between two quaternions to get a part-way
rotation, avoiding the gimbal problems of the more conventional euler angle
interpolation.
Quaternions only have floating point versions, without any _f suffix. Other
than that, most of the quaternion functions correspond with a matrix
function that performs a similar operation.
Quaternion means 'of four parts', and that's exactly what it is. Here is the
structure:
typedef struct QUAT
{
float w, x, y, z;
}
You will have lots of fun figuring out what these numbers actually mean, but
that is beyond the scope of this documentation. Quaternions do work -- trust
me.