Jump to content
  • Advertisement
Sign in to follow this  
SpacedOut

Question about quaternions

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

OK, I've been doing research on quaternions, but I'm still a little confused. I know the format quaternions are represented in is: [ cos(theta / 2), ( sin(theta / 2)x, sin(theta / 2)y, sin(theta / 2)z )] and I've been told they're used like an axis-angle representation of orientation. But let's say I want to represent a rotation of 0 radians along the Z axis, facing in the negative Z direction, like the default in OpenGL, my quaternion comes out to: [ 1, (0, 0, 0) ] and let's say I wanted to rotate to zero degrees along the Y axis facing the negative direction, I can't figure out how to do that. I realize I'm just not getting this, any help appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by SpacedOut
OK, I've been doing research on quaternions, but I'm still a little confused. I know the format quaternions are represented in is:

[ cos(theta / 2), ( sin(theta / 2)x, sin(theta / 2)y, sin(theta / 2)z )]
To be a little more accurate, a quaternion is just a mathematical entity; the above rotation form is one interpretation of a quaternion (albeit a common one).
Quote:
But let's say I want to represent a rotation of 0 radians along the Z axis, facing in the negative Z direction, like the default in OpenGL, my quaternion comes out to:

[ 1, (0, 0, 0) ]

and let's say I wanted to rotate to zero degrees along the Y axis facing the negative direction, I can't figure out how to do that.

I realize I'm just not getting this, any help appreciated.
There's no such thing as a 'rotation of 0 radians along the Z axis', so you may be a bit confused there.

All rotations can be reduced to a rotation by a single angle about a single axis (the axis-angle form you referred to). In your example, it sounds like you want a rotation that rotates a vector (the forward vector) from the -z to -y axis; the most direct of these is a rotation of -90 degrees about the +x axis (or, equivalently, 90 degrees about the -x axis).

By the way, the use of quaternions is completely incidental in this problem. It might be best to instead think of it in terms of vector, matrix, or axis-angle rotations until you've got the underlying concepts down. Then, you can introduce quaternions if you have some particular need for them.

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!