Why do game programmers use quaternions to rotate a vector?

Started by
33 comments, last by dawidjoubert 18 years ago
To annoy Diana Gruber.

That was one of the first articles I read on gamedev.net [grin] Also one of the most vitriolic forum conversations for the time. Both Mrs Gruber's article and the forum posts are still worth reading though. I'll sit on the fence on the actual subject though, as it is a religious flamewar.
Advertisement
Well, it isn't so religious. Math is different from religy; if i'd say that under rules of arithmetics 2*2=5 and you'd say 2*2=4 , i'd actually be wrong.

She deliberately avoided discussing how to do concatenaton of transformatons and SLERP with axis-angle representation (or, rather, she discussed SLERP but a: her implementation of SLERP is incorrect, b:it's also more complicated (more operations).
Fast concatenation of transformations and good SLERP (and higher order interpolations) is the main reason "why use quaterions".
If you are not doing either, then indeed you could just use matrices instead. But nearly any serious project will need both.

Really, quaternions and quaternion multiplication can be described as axis-angle with less trigonometry (quaternion elegantly stores axis of rotation and sine and cosine of half angle).
That is, to concatenate two axis-angle rotations you will essentially need to compute sine and cosine from angle, and then later find angle from sine and cosine; with quaternions, essentially, redundant trigs is simplified out.
Same with rest of stuff; at best, *in special cases*, axis-angle does things with same number of operations. But in other cases, to work with axis-angle you'll need direct and inverse trigonometry.

Quaternions and axis angle is kind similar to complex numbers and complex numbers in polar coordinates. There's some use of complex numbers in polar coordinates, but you normally don't write general complex number libraries using polar coordinates, for exact same reasons.

As for controversies, all it takes to start controversy is one mistaken person with experience who doesn't admit mistake (then, roughly half of clueless folks who heard both sides will stick to one side and other half to other, and there will be some equally clueless folks who will say it's controversial and that both sides is right etc.)

[Edited by - Dmytry on April 4, 2006 5:50:57 AM]
@sonyafterdark: It's good that you're thinking about these issues and not accepting things just because they're established convention. Still, being too rigid and not being open to the combined knowledge and experience of an entire industry can slow you down if you're not careful.

One thing I wasn't clear on from your posts is why 'equations' are more precise than matrices. You also didn't really address the issue of concatenation, and that a single 4x4 matrix can take a vertex from a local space deeply embedded in a hierarchy directly to clip space with a single matrix-vector multiplication. Beat that :-)

You mention that you've never implemented hierarchical transformations, and that interpolating rotations is 'out of your hobbyist programmer league'. There's nothing wrong with being a hobbyist (I'm one myself), but you might ask yourself, if basic topics such as these are 'out of your league', are you really qualified to question the fundamentals of 3D graphics as established over the past several decades by countless industry professionals?
Quote:Perhaps you should review the basic 3D math you think you know before lecturing others about the obvious advantages of using quaternions and matrix operations and seeking to implement redundancies in a program's code as much as possible.
Oh now that's just silly :-)
Quote:Original post by gregs
To annoy Diana Gruber.

That was one of the first articles I read on gamedev.net [grin] Also one of the most vitriolic forum conversations for the time. Both Mrs Gruber's article and the forum posts are still worth reading though. I'll sit on the fence on the actual subject though, as it is a religious flamewar.
As Dmytry suggested, there's really nothing religious about it; it's just a matter of being suitably informed. Nobody who really understands the subject would waste his or her time asking such silly questions as 'do we really need quaternions'; the truly informed will simply consider the options and choose the best tool for whatever job is at hand.
Quote:Original post by Sneftel
Which is often a very bad thing. Similarly, you could use strings to represent all the integers in your program, because they can do much more than just numbers. It is entirely possible to have too much expressivity.


Aren't strings commonly used to represent integers? Each digit in the string corresponds to the coefficient of a term of a polynomial.

That's how it works for natural numbers at least.

Quote:Original post by The Reindeer Effect
Quote:Original post by Sneftel
Which is often a very bad thing. Similarly, you could use strings to represent all the integers in your program, because they can do much more than just numbers. It is entirely possible to have too much expressivity.


Aren't strings commonly used to represent integers? Each digit in the string corresponds to the coefficient of a term of a polynomial.

That's how it works for natural numbers at least.


Well yes, but then we are working with equations (polynomails). You cant store 2x + 1 in an integer so it would go into a string. HOWEVER once the program analises it, it would probably convert it into this format. x[1] = 2, x[0] = 1 ,x[n] = aX^n where as you see n is the power.

Then again if we use utf-16 to store numbers we can store numbers like .666666666 in a string like this 2/3 and never lose accuracy!!!!
----------------------------

http://djoubert.co.uk

This topic is closed to new replies.

Advertisement