If we want to model 3 dimensional rotations, is it best to use matrices or quaternions?
Pure Rotations
If we want our program to combine 3 dimensional rotations then we have a choice of using 3x3 matrices or quaternions. So which should we use? Provided that we constrain the values in the matrix to be an orthogonal matrix then both algebras are mathematically equivalent so our choice can be made on practical issues.
The advantages of quaternions are:
- Each quaternion only requires 4 scalars whereas a matrix requires 9 scalars.
- It is easier to interpolate between quaternions using SLERP as explained on this page.
- Quaternions are easier to normalise than matrices (to cancel out a build up of small rounding errors).
The advantages of matrices are:
- Transforming a point seems simpler by multiplying a vector by a matrix rather than the sandwich form required for quaternions.
- People often find matrices easier to understand than quaternions.
- There are more ready built matrix libraries than quaternion libraries.
Conclusions
I don't think there is a clear winner, it depends on what you are most comfortable with and what tools are available for your program. I have not done any tests of relative speed but I don't think there is much to choose between them, the matrix has more scalars but this is cancelled out by the more complicated equations for transforming a point.
Isometries and Physics
If we want to model isometries, such as the movement of solid bodies, combining rotation and translation, in one single operation, we need to expand the above algebras to model translations as well as rotations.
To model isometries we could either:
- Expand matrices to 4x4 as described on this page.
- Expand quaternions to dual quaternions as described on this page.
Again matrices tend to be easier to understand for most programmers, dual quaternions have a lop sided multiplication table in which some dimensions have non-zero values which square to zero.
So can we extend these algebras to model physics? For example, modeling forces/torques and their effect on linear/angular acceleration. To do this we need to:
- Extend the inertia tensor to a 6x6 matrix which includes mass as described on this page.
- In his books, Hestenes explains how Geometric Algebra can model tensors and how it is less dependant on the choice of coordinates, but I don't understand this yet but I'm still working on it.
Conclusions
So far, matrices seem to be able to model of these things than quaternion-like algebras, but I'm still working on this and I think that Geometric algebra may have a lot of advantages.