 # are the quarternions the best option?

Hi all,

I have been doing some tests with Quaternions and matrices and the speed is very similar (i think i did a good implementation).

It’s true that Quaternion Algebra is useful to “easy” orient rotations but are the Quaternions really necessary having euler angles and standard matrices since Quaternions doesn’t speed much.

Thanks, and sorry for my english The only obvious advantage I personally see to using quaternions, is that spherical linear interpolation of quaternions is simple. However, some people may feel that slerping can be just as easily done using axis-angle constructs. Use what you feel gets the job done and doesn’t bring in too much mystery (I’d rather understand the algorithm being used rather than use something just because it works for some unknown reason).

Other advantages are that Quats take up a lot less space and they are much less prone to numerical drift and when they do they are faster to normalize than a matrix.

The space part is debatable. Sure they are smaller than a full matrix, but a full general matrix contains more info than a quarternion does. If you reduce a rotational matrix to an axis and angle, then it is the exact same size as a quaternion. And an axis-angle pair does not suffer drift any worse than a quarternion.

Well, quaternionquaternion is faster than matrixmatrix, even for 3x3 basis matrices, and the quat-to-matrix conversion is faster than the axisangle-to-matrix conversion. To be honest though, the speed and space issues are red herrings. I’ve made no particular effort to optimize my math code and it still doesn’t clock up to 0.1% in the profiler. And with the average 3D entity weighing in at hundreds or thousands of verts plus textures, a few bytes here and there are largely irrelevant.

Use whatever seems most natural. Personally I store current orientation as a quat, multiply it by a rotation axisangle, and store the result in a (constrained) matrix for rendering. YMMV.

Originally posted by MikeC:
Well, quaternionquaternion is faster than matrixmatrix, even for 3x3 basis matrices, and the quat-to-matrix conversion is faster than the axisangle-to-matrix conversion.

Hardly… especially if you optimize it. Quat math involves higher-order math functions, where as matrix math is mostly straight arithmetic or a single trig function. And the conversion is just as simple.

Siwko

For me the obvious reason is that a Quaternion uses 4 (as opposed to 9 for a Matrix) to describe the rotation. This means that if you plan to incorporate physics, the drift encountered when integrating is much less!

And skewing only occurs when the quat loses its unit length, the same happens with the matrix when it no longer is orthonormalized. I.E. it is more expensive (computationally) to keep the rotation from skewing your object.

hope I made any sense If that’s your only reason, why not use an axis-angle pair?

Originally posted by Siwko:
Hardly… especially if you optimize it. Quat math involves higher-order math functions, where as matrix math is mostly straight arithmetic or a single trig function. And the conversion is just as simple.

Matrix33*Matrix33: