Sign in to follow this  
Kryogenik

Convert Quaternion to Yaw Pitch Roll

Recommended Posts

I am messing around with Havok, and I'm trying to position and rotate my object the same as the corresponding rigid body in havok. The rigid body has getPosition and getRotation functions in it, which is good. But the getRotation function returns a Quaternion.

From what I understand, a Quaternion is made up of 4 numbers. The first 3 being x, y, and z values in an axis vector (or whatever you call it), and the 4th being the amount of rotation around that axis. But thats all I know about Quaternions, since I have no experience with them and have been using Yaw, Pitch and Roll for 3d rotations since I started making 3d games.

Is there any way I can get the Yaw, Pitch and Roll for my object from the Quaternion havok returns? Thanks.

Share this post


Link to post
Share on other sites
Here's also a nice help site on all things math for 2D, 3D applications and programming in general (linked to his quaternion page):

http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/index.htm

Quaternions are just one way to represent a rotation and themselves can be a bit less cumbersome to use (as opposed to lugging a rotation matrix around). A common reason for not using euler angles is because you have the chance of gimbal lock - where you lose a degree of freedom. Bringing the rotations into 4D space helps prevent this.

Here's some more information about gimbals:

http://en.wikipedia.org/wiki/Gimbal_lock

Share this post


Link to post
Share on other sites
Quote:
Original post by Starnick
Bringing the rotations into 4D space helps prevent this.
That's not correct, I don't think. You can avoid gimbal lock as easily with matrices as you can with quaternions, so it doesn't seem to me that the 4-d aspect would have any bearing.

Share this post


Link to post
Share on other sites
We're not talking about Matrices here but Euler Angles vs Quaternions. Euler angles have the singularity issue that results in gimbal lock. I'm pointing out that rotation Quaternions represent a rotation in 4D space and do not have the problem euler angles have. You could do the same just with Angle-Axis, or as you pointed out just using plain old rotation Matrices all the way through. I should have been clearer on this.

Getting back to the original topic, Kyro I would stick with Quaternions. Euler angles can make more sense to us opposed to a Quaternion, but you probably will have an easier time just using the quaternion that gets returned to you.

Share this post


Link to post
Share on other sites
Quote:
Original post by Starnick
We're not talking about Matrices here but Euler Angles vs Quaternions. Euler angles have the singularity issue that results in gimbal lock. I'm pointing out that rotation Quaternions represent a rotation in 4D space and do not have the problem euler angles have. You could do the same just with Angle-Axis, or as you pointed out just using plain old rotation Matrices all the way through. I should have been clearer on this.
I understand - I was just pointing out that it's not the 4-d space aspect that prevents gimbal lock (in that respect at least, it seemed to me that the statement '[b]ringing the rotations into 4D space helps prevent this' was a bit misleading and potentially confusing).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this