Jump to content
  • Advertisement

Archived

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

baskuenen

Quaternions - Why use them?

This topic is 6666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve read a lot of information over them on the net. I probably can implement and use em now, but I ask myself - what''s the use? Most things I want I can do without quaternions. Can somebody please give me a short practical example, where you must use quaternions?

Share this post


Link to post
Share on other sites
Advertisement
What are the things you want to do?
Quaternion are useful in interpolating between two orientations. Like in tomb raider you turn your character but you notice the surrounding doesn''t turn as fast as your character, at that point the camera is following a interpolation between the two orientations.. you can try to do specify it with euler angles but you might get a gimbal lock. I think that''s it. Someone correct me if I''m wrong

Share this post


Link to post
Share on other sites
Thanks, thats the only conclusion I can come up with:
Interpolating between 3D angles

Is this the only use for quaternions?

Share this post


Link to post
Share on other sites
I never understood why people think they have to use quaternions to interpolate. You can use the 3 vector (UVN) viewing system and interpolate between vectors. This system works much better with matrices and the math is all normal.

http://3d.n3.net/

Share this post


Link to post
Share on other sites
the computer can calculate rotations quicker with quaternions , though this is only really useful if youre doing someit that needs speed like a 3d engine hehheh

Share this post


Link to post
Share on other sites
Some time back, I wrote a space simulator (or something that looked like it...) I uses the vectors of different object to make a "homing-algo". (a homing missile chasing a ship)
If I remember correctly - I used the crossproduct to get the vector between the two objects - then used the dot product to calc the angle. Afterwards rotated around this cross product vector...ect...

- It worked just fine -

zedzeek: I see - quaternions CAN be faster if you''re doing a lot of angle calculations after another. But (correct me if I''m wrong) to calc a quaterion from a matrix and back - you''ll need a lot of extra calculations just to convert.

My believe in quaternions is fading...


Share this post


Link to post
Share on other sites
To tell you the truth, I myself don''t know why they use them. But, I''d imagine it has to do with the "smooth" movement that you see in Tomb Raider''s camera system.

OldManDave.

Share this post


Link to post
Share on other sites
Oke guys, I think I''m getting it now!? - Quaternions are only used for smooth 3D angle interpolations.
I used to think they could be used for lots of more stuff.
Maybe I''ll do some more investigating on quaternions when I really really need them...
For the moment I guess there are more interresting and usefull things to learn...

All I can say: - Don''t believe the hype!

(ps: please prove me wrong hehe)

Share this post


Link to post
Share on other sites
From what I''ve read, quaternions are a bit more useful than merely producing smooth rotations. Also, they may be more computationally cheap than you think. Gamasutra has a really good article on them and I''d recommend you read that if you want more info after reading the one that was made for gamedev.

The biggest advantage I see is avoiding "gimbal lock", or the loss of one DOF due to compound rotations using the euler rep method. Also, it''s computationally cheap vs. the angle rep method when you''re interpolating between orientations (and want it to be smooth).

However, the gimbal lock problem doesn''t occur if you aren''t compounding angles/using all 3 DOF. So, if you only plan on rotating about 1, maybe even 2 axes, then you might not have this problem. However, if you are rotating about 3 DOF, gimbal lock may occur with the euler method and angle axis methods.

I guess it really depends on your application and how much freedom you want when moving objects about.

Just be warned, I''m not an expert by any means, but, it''s just from my observations.

-Division-By-Zero

Share this post


Link to post
Share on other sites
A single quaternion is made of 4 values (w,ix,jy,kz).
A single matrix is made of 9! values (3*3)

You can do exactly the same things with quaternions as with matrices, but far more efficiently.
Now in your 3D engine you would use only quaternion math, and eventualy convert the final quaternion to a full 4*4 matrix to give it to the 3D API (D3D or OpenGL) that uses only matrices.

As for the gimble lock, as said before, it''ll happen only if you rotate arround the 3 axes at the same time.

So the quaternion advantages would be:
smooth orientation interpolation,
no gimble lock,
fast & efficient math.

A disadvantage:
no translation & no scaling information

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!