Why Diana Gruber's wrong about Quats

Started by
163 comments, last by Shaterri 20 years, 10 months ago
quote:Original post by Tom
Where can I find a tutorial on using quaternions?


Try the tutorial section here..

..

Advertisement
quote:Original post by Tom

I''m familiar with vectors and matrices, and I''ve heard you can do some neat things with quats. Now is the time for me to find out the truth myself. If there''s one thing I''ve learned in my years, it''s never to trust another person''s opinion.



That''s a very healthy attitude, Tom! I learned about quaternions by going to a search engine and typing in "quaternions". I used altavista. There is tons of material available.

Also, that Dave Eberly guy apparently has a new book out on the subject. His URL is http://www.magic-software.com/. I haven''t read the book yet, but I see he includes these sections:

> 2.3.3 Conversion Between Angle-Axis and Rotation Matrix
> 2.3.4 Conversion Between Quaternion and Angle--Axis
> 2.3.5 Conversion Between Quaternion and Rotation Matrix

His section 2.3.3 would correspond to my Part II, and his section 2.3.5 would correspond to my Part I. It will be interesting to see how his equations compare to mine. (There are no doubt many ways to do it.) It will also be interesting to see if he drew the same conclusions I did. (I think he is pro-quaternion.)

Hmmm... I think I better buy the book.

Diana

P.S. Anybody going to the XGDC conference next weekend? I''ll be there! Andre is making me give a presentation on 3D math.
Diana,

I''ll be at XGDC. Andre''s making me do a talk as well, on stability analysis for physics programmers.



Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
email: grhodes@sed.ara.com
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Graham,

That Andre''. Always making people do things.

Be sure to introduce yourself if I don''t recognize you. I imagine I''ll stand out in a crowd more than you will. It''s a blonde thing.

See you Sunday,
Diana
quote:Original post by dgruber
To all the people who have emailed me saying that quaternions save time because you can pass less data across the network... what makes you think vectors require more data than quaternions? Describing a rotation requires a fixed, minimal amount of information, no matter how you represent it. Vectors don''t require more information than quaternions. The difference is in the operations, not in the data.


You are correct that a matrix doesn''t store a orientation however a vector doesn''t store an orientation either. It just stores a location in space. In my code (which uses matrices, I don''t have the time to convert to quaternions) I have a orientation structure that holds the location (3 values), to angle on each axis (3 values), and 3 more values used for scaling. That''s 6 values needed to specify orientation. A quaternion only needs 4 and doesn''t require a seperate data structure like I have. If you were to somehow merge the orientation values into the vector you''d probably end up with something that looked like...a quaternion! My experience in 3d programming is probably minimal compaired to some of the other posters but this technical point here some kinda'' obvious to me.
I''ve just read Diana Gruber''s article and also want to pick up on some of the points raised in the discussion since.

Quaternions are used to represent rotations in 3D. As there are only three degrees of freedom in 3D rotations it seems sensible that a three element vector, such as one of Euler angles, could be used.

But it has been established that all three-element representations of rotations in 3D contain singularities, i.e. there are rotations which can be represented by more than one set of elements. In the case of Euler angles the singularities depend on the order the angles are used, and correspond to ''gimbal lock'' positions.

So at least four elments are needed. One possibility is an angle-axis representation, but this also has the null rotation as a singularity, as it can be represented by a rotation by no amount about any axis.

Any represtation with such singularites is an order of magnitude more difficult more difficult to deal with than one without, as questions such as
what is the representation of this rotation ?
what rotation comnined with this one gives me a third ?
how close are these two rotations to each other ?
how to interpolate smoothly between two representations ?
are far more difficult if not indeterminate/impossible.

The unit quaternion representation of rotatinos contains no singularities, which on it''s own makes it superior to any 3-vector based and angle-axis representations. It is not the only singularity free representation. 3x3 orthogonal matrices are another. Cayley-Klein parameters are another.

As quaternions and matrices are the only representations widely used it will be most useful to compre them, and quickest to do so by asking a series of questions.

Which are more compact ?
Quaternions
Which are quicker to derive ?
In my experience quaternions, though this depends on the methods used and what they are derived from
Which are quicker to invert ?
Quaternions
Which are quicker to multiply ?
Quaternions (16 multiplies vs 27)
Which are quicker to interpolate ?
Quaternions by far (I know of nothing equivalent to SLERP for matrices)
Which are most stable ?
Quaternions. By stable I mean which suffer least from numerical drift in dynamics simulations. Matices drift away from normal/orthogonal far faster than quaternions, and so need to be renormalised more often, a far more expensive operation for matrices.
Which are faster to use ?
Matrices. By use I mean apply to a 3-vector to effect a transformation, and matrices are generally much faster as the appllication of a matrix can be more easily parallelised on modern processors.

So for everything except generating a rotation quaternions are faster. In general if a program does any significant work manipulating - i.e. using, combining, recalculating - rotations it should be faster using quaterions, though the exact benefits depend on factors such as whether an optimised quaternion library exists or whether you are willing to create one.

In my code all of the dynamics and geometry calculations use quaternions, wih inputs generally calculated from angle-axis. These are eventually output to be converted to matrices for the graphics engine.

john

John Blackburne
Programmer, The Pitbull Syndicate
John BlackburneProgrammer, The Pitbull Syndicate
John,

When you state a whole bunch of mathematical facts like that, you are supposed to provide proof. By that, I mean rigorous mathematical proof. That's how the system works.

I had one kid in email who argued this was not necessary. He said you can do valid mathematics without ever proving anything. He also took exception to my statement that "software engineers are not mathematicians." He tried to convince me that since he had taught himself how to use quaternions, that qualified him as a mathematician.

Funny, I have a degree in math, and I don't consider myself a mathematician. Mathematicians are somewhere above me. I'm just a formula scribbler and code dabbler. But I'm pretty sure about the proofs thing. In all my math classes, that's how things were done. You had to prove it, or you couldn't use it.

quote: Original post by johnb

Which are quicker to interpolate ?
Quaternions by far (I know of nothing equivalent to SLERP for matrices)



Just because you don't know of it doesn't mean it can't be done. I've thought of 4 different ways to approach the slerp problem in R3. When I get time, I'll work on reducing the operation count. That's the key, isn't it? Minimizing the operation count? When I get it, I'll publish another paper here.

So, if I solve the slerp problem without quaternions, will I be some kind of a hero? Or will people just flame me worse for knocking down their false idols?

I'm off to XGDC this weekend to present my paper on rotations. Here's a sneak preview: http://www.makegames.com/3Drotation.

Diana


Edited by - dgruber on September 28, 2000 11:48:10 AM
I know nothing about quaternions and very little about vector maths, so I offer an outside perspective. If you can implement quaternions in your code then all respect is due to you, but, regardless of how efficient they might be I would never consider using them myself unless I really had no other choice, for the simple reason that I find it impossible to visualize them. As Diana says - you can draw a picture of a vector. Using quaternions, in my case, would feel too much like running very fast with my eyes shut. I am sure they do have their uses, however (and if you can picture them in your head N.A.S.A. would probably like some help with their new spaceship :-), but it seems to me that the advantage of being able to implicitly understand my code would outweigh speed or even functionality increases. Others may disagree and this is probably because I am wrong... I am open to this possibility so please don''t mail me with detailed accounts of exactly how mistaken I am :-)

Mostly I just wanted to say, having read both of Dianas recent articles, how refreshing and USEFUL it was reading complete sentances and seeing proper mathematical notation and proofs. I have battled with far too many tutorials that don''t consider these things important. I appreciate the effort put into them and am always ready to absorb new information whichever format it appears in, but the rules of both languages (English and maths) evolved to make communication and understanding easier. I hope that when I write a tutorial it is presented as professionaly. Thanks Diana. Now I''m going to go through them again, very slowly, and one day I might know what you''re on about :-)

Lastly, I wanted to comment on some of the apparent animosity which surrounded this subject (?...I feel silly just talking about it). Yeah, Diana took a few pops at quaternion fans, and even programmers in general, and Shaterri responded in kind, fair play on both sides in my opinion. Can''t we take this sort of thing with a pinch of salt, or are we really going to have to restrict discussions to purely technical matters? Anyone looking for a crusade might like to know that there are more people on this planet bound in slavery right now than there has ever been in all of human history - if you still care about matrices and quaternions, I know a good doctor.

Stephen

Geocyte Has Committed Suicide.
Geocyte Has Committed Suicide.
I''ve been loosly following this thread and haven''t felt compeled enough to say anything because I''ve never implemented quaternions, but Geocyte''s comments on visualization is right down my ally. Having several years of some pretty intense math under my belt, I''ll say that being able to visualize something is probably the ultimate in understanding a concept. However, you must be able to understand stuff without visualizing them - just by making sense of the numbers. This pretty much will only come from knowing every line of a proof. Therefore, proofs are VERY necessary in pretty much everything, even if it is something that you can visualize, you will probably have a deeper understanding by going through a proof of it. Now, how you can visualize some arbitrary rotation matrix and not a simple quaternion is almost beyond me. If you didn''t know the exact construction of the matrix, you''d probably have to diagonalize it to have chance at seeing what it is doing, and then is still might be a bit ambiguous. Versus the quaternion which if i understand correctly (i''m a bit out of my element here) closely resembles the axis/angle system, which is really easy to visualize.


JS
http://www.thepeel.com/void
JShttp://www.thepeel.com/void
Stephen,

Thanks for the kind words. Actually, I feel kind of lucky to have stumbled on this problem. It is unusual to find an area of research that needs work like this. Just when it seems like everything under the sun has been done to death, here''s a little corner of mathematics for Diana to explore and document. Lucky me.

That''s why I am going to work on the slerp problem some more, even though I''m real busy and I don''t see it as "paying" work. I''d like to be the first to publish a solution that is 1) easy to understand and draw and 2) computationally efficient. I would feel privileged to be able to publish something like that, because it would be like adding to a body of knowledge that smarter people than me have been building for years.

I think I''m close. I think I know how to do it.

J.S., visualizing a rotation from a matrix is easy. Just think of a little 3-axis coordinate system floating around in space. Each row of the matrix is a vector of length 1. The bottom row is z'', the middle row is y'' and the top row is x'', or as it is usually called, Out, Up and Right. I drew pictures and explained it in detail in my article at makegames.com.

Diana

This topic is closed to new replies.

Advertisement