Need to model the rotations of a rigid body in six-degrees-of-freedom? Use quaternions.They are *very* cool. I have written a small Matlab/Octave library of functions, for modelling rotations with quaternions. It includes an animated demonstration script which lets you visualize the rotations (see the .gif above). This is really useful for sanity checking your code and helping you to understand what's going on.

Download the 'manageQuaternions' library here: