Jump to content
  • Advertisement
Sign in to follow this  
staticVoid2

quaternions help

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

hi, I'm currently trying to load and animate a mesh, there are three animation keys - scale(vector), translate(vector), and rotate(quaternion). I'm having trouble understanding what a quaternion actually represents, I've been reading up on complex numbers and understand how they work, basically representing a real number with an imaginary i where i = sqrt(-1). I read somewhere that a quaternion can be thought of as a 3d vector and a rotation value(euler(i think?)) in 3d space, is this true or is it more complex?

Share this post


Link to post
Share on other sites
Advertisement
Geometrically, you can think of a quaternion as a vector and an angle of rotation around that vector. However, these values are not stored directly in the quaternion.

If you have a vector v = (x, y, z) and an angle A, and you want to construct a quaternion (qw, qx, qy, qz) that represents a rotation by A degrees around v, you would do this:

qw = cos(A/2)
qx = sin(A/2) * x
qy = sin(A/2) * y
qz = sin(A/2) * z

Share this post


Link to post
Share on other sites
Quote:
Original post by staticVoid2
I read somewhere that a quaternion can be thought of as a 3d vector and a rotation value(euler(i think?)) in 3d space, is this true or is it more complex?

I would not try to interpret anything from the values of a quaternion; trust me, it will not work in general but produces headache. E.g. think of a rotation of 180° around any axis; the equivalent quaternion is [ 1 0 0 0 ]T. If you interpret that geometrically then it appears as a rotation around a vanished axis. So don't do it.

A quaternion, to be exact a _unit_ quaternion, is just another representation of rotation. Keep them as a mathematical tool, and that's it.

There is a concrete axis/angle representation for rotations as well. Those representation defines a plane (yes, mathematically there is no _axis_ of rotation but a _plane_ of rotation, and the plane is given by its normal what is often named the "axis"; that's the reason why rotation works also in 2D) and a single angle denoting how far the rotation goes. That angle has nothing to do with Euler angles. However, the axis/angle rotation can easily and exactly be interpreted in geometrical terms. And it is very easily converted to quaternion and vice versa (see e.g. Gage64's post above). The formulas of the conversion misleads one to think of quaternions geometrically, but, as said, I urge you not to do so.

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!