• ### What is your GameDev Story?

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

## 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 on other sites
Quote:
 Original post by SpacedOutOK, 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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 31
• 16
• 11
• 10
• ### Forum Statistics

• Total Topics
634122
• Total Posts
3015617
×