Archived

This topic is now archived and is closed to further replies.

Lode

Quaternions vs my favourite matrix

Recommended Posts

Why to use quaternions if you can rotate vectors in any direction with this matrix:
  
//      [tx²+c   txy+sz   txz-sy   0]

//  R = [txy-sz  ty²+c    tyz+sx   0]

//      [txz+sy  tyz-sx   tz²+c    0]

//      [0       0        0        1]

//

//  where c = cos(a), s = sin(a), t = 1-cos(a)

//        l = unit vector on rotation axis

//        a = angle of rotation

//        x, y and z are the coordinates of v

  
? I didn't get any gimbal lock problems with it yet (all I've moved so far is the camera). What do quaternions have that this matrix in combination with vectors doesn't have? EDIT: omg this looked terrible without source tags [edited by - Lode on July 28, 2002 6:18:22 AM]

Share this post


Link to post
Share on other sites
3x3 matrices and quaternions essensially provide EXACTLY THE SAME FEATURES.

so why quaternions?
simple.
while the math looks scary, if you know complex numbers and all that, they are easy to understand.. matrices as well, but i just want to state quaternions are nothing magic

small.
you need 4 floats, else you need 9. that can be very handy for example in vertexshaders, with bone animations.. three times the amount of orientations storeable in the constants.

accurate.
matrices can deortogonalize due numerical instability, quaternions as well. but quaternions you can simply normalize and they are perfect again. i had yet problems with this, even while its normally a small problem..

fast.
concatenating quaternions is faster than concatenating matrices. this, again, very useful for bone-animations, or if you do physics and your orientations change due some complex algo, etc..

restriced.
a normalized quaternion is always a rotation/orientation, if not normalized it has scaling in as well. a unit quaternions is NOTHING but a rotation/orientation..
a 3x3 matrix can mean much much more than rotations/orientations..
when i have to store an orientation, i prefer a unit quaternion. there is NO chance that its NOT an orientation..
if i need to store a general transformation, i''ll choose a matrix, if i need a rotation, i''ll choose a quaternion, if i need a translation, i''ll choose a vector. that simple..

someone said one time. perfect is not, when you can''t add anything, perfect is, when you can''t remove anything.
thats why it is more useful to use quaternions for rotations. matrices have too much in.


anyways, matrices work, and they work well. if you like them, stick with them.. i''ll suggest you dive into quaternions anyways to learn their power as well, so you can choose because of knowledge, not because you don''t know it..

hope this helps a bit..

this can now start to get a religious war here in, don''t bother. both are useful, both work well. i prefer quaternions over matrices simply cause i don''t like matrices. dunno why (possibly because they contain everything combined, i love to split)

"take a look around" - limp bizkit
www.google.com

Share this post


Link to post
Share on other sites
i forgot to mentoin. most people say slerp(quat,quat,float) is useful. you can interpolate between two or more orienations in a very nice way, wich is difficult (but not impossible..) with matrices

(why difficult, but not impossible? because they do essencially the same, you can say slerp(matrix,matrix,float) == quat2matrix(slerp(matrix2quat(m1),matrix2quat(m2),float)) and you can calc and write out this on paper and you get: matrix slerp(matrix,matrix,float) ..)

"take a look around" - limp bizkit
www.google.com

Share this post


Link to post
Share on other sites
Hey thanks for some very interesting points!
I''ll certainly give quaternions a try, I''ll have to change a lot of code for it, but you''re right about knowing is better than not knowing and once I implemented them I may even want to keep them .

Share this post


Link to post
Share on other sites