[Papervision3D] Quaternions vs matrix

Jon Bradley jbradley at postcentral.com
Tue Jan 16 13:10:27 EST 2007


Carlos wrote:

> I believe quaternions are slightly slower due to the increased  
> number of values. But they have two unique advantages, no gimbal  
> lock and easier rotation interpolation. So they probably come in at  
> some point.


All true on the quaternion stuff except that gimbal lock is only an  
issue if you don't have an order of operation set up properly for  
euler rotation. It's a pretty common misconception that using  
quaternions is a reason to avoid gimbal lock.  But, you probably know  
that already. :)


And Anthony wrote:

> Matrix math will be a lot faster in the long run (& less calculations
> like you said) when you have quite a few faces, objects & hierarchy,
> plus it helps out with the lighting & clipping (I never got that far).

Matrix math with a 4x4 matrix isn't too much faster than a  
Quaternion. Of course, that all depends on what you're doing with  
them and how many operations you've got.

> I did look at quaternions first (I think one of the old flash examples
> uses this), but I knew a lot of the matrix math so went with that.
> Quaternions is harder maths and I could not figure how to get them to
> multiply down the hierarchy like the matrices.


Quaternions are just as easy to code as matrices actually. The issues  
arise when you are converting a Quaternion to a rotation matrix,  
which should be a 4x4 (not 3x4).

I've written a Quaternion class that I can provide to the project if  
you like. It's written in C (I had an AS2 conversion around here, but  
I can't seem to find it right now) and shouldn't take too long to  
convert to AS3.

I'll see what I can do to make it available.

cheers,

jon



More information about the Papervision3D mailing list