3D Theory - Matrix vs. Quaternion

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:

The advantages of matrices are:


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:

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:


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.

metadata block
see also:
Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

flag flag flag flag flag flag New Foundations for Classical Mechanics (Fundamental Theories of Physics). This is very good on the geometric interpretation of this algebra. It has lots of insights into the mechanics of solid bodies. I still cant work out if the position, velocity, etc. of solid bodies can be represented by a 3D multivector or if 4 or 5D multivectors are required to represent translation and rotation.


Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

cover Dark Basic Professional Edition - It is better to get this professional edition

cover This is a version of basic designed for building games, for example to rotate a cube you might do the following:
make object cube 1,100
for x=1 to 360
rotate object 1,x,x,0
next x

cover Game Programming with Darkbasic - book for above software

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2015 Martin John Baker - All rights reserved - privacy policy.