Jump to content
  • Advertisement
Sign in to follow this  
Kambiz

Why do game programmers use quaternions to rotate a vector?

This topic is 4516 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

Advertisement
Do game programers do so? Yes, but very seldom. In fact the matrix vector product is much better suited to rotate a vector.

However, quaternions are good for operations occuring _before_ rotating a vector, namely in intra-/extrapolating rotations, in concatenating rotations, and a bit also in storing rotations (if the memory footprint plays a remarkable role).

But, hey, formula 4) seems me a look worth ;) That is an axis/angle pair rotation, right?

Share this post


Link to post
Share on other sites
Because sometimes, rotating a vector is not the goal, it's part of the process you must follow, in order to achieve the goal.

And quaternions -sometimes- make it easier to achieve some goals, than just rotate a vector.

Share this post


Link to post
Share on other sites
Quote:
Original post by haegarr
But, hey, formula 4) seems me a look worth ;) That is an axis/angle pair rotation, right?

Yes

Quaternion rotations are easy to combine, that is a good reason to use them, but I think many programmers use quaternions just because they do not know formula 4 or think that quaternions are cool!

Share this post


Link to post
Share on other sites
Quote:
Original post by someusername
And quaternions -sometimes- make it easier to achieve some goals, than just rotate a vector.


Give me an example.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I saw an engine once that serialized rotations as a quaternion using 3 8-bit values. It used w = 1-sqrt(x^2+y^2+z^2) (or something like that) when it loaded them from disk, then converted that to a 3x3 matrix. So basically it compressed the 3x3 matrix down to 24-bits.

Not sure I'd do that, but it seemed to work okay.

Share this post


Link to post
Share on other sites
Quote:
Original post by someusername
Orientation interpolation at constant angular speed


Why do you need a quaternion? In classical mechanics people use just a vector and it works well.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
I saw an engine once that serialized rotations as a quaternion using 3 8-bit values. It used w = 1-sqrt(x^2+y^2+z^2)...
Not sure I'd do that, but it seemed to work okay.


The same way you can use a vector to represent the rotation... as you see you just need 3 values x,y,z and w is useless.

Share this post


Link to post
Share on other sites
You're talking about the angular velocity vector which describes the instantaneous rate of change of an object's axes.
I'm talking about arbitrarily setting the object's axes to any two orientations, and interpolating smoothly from one to the other.

If you just want to rotate a vector, there must be a million ways. You could even change to spherical coordinates, offset the angles and reproject to cartesian.
Have you seen anyone using that? It's all a matter of what you want to achieve in the first place.

And I said "quaternions sometimes make it easier", not that they can do something when there is no other way.
Anyway, I don't feel like arguing about this. Anyone who has ever used them can decide for themselves whether they are worth the fuss.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!