# Convert Quaternion to Yaw Pitch Roll

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

## 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 on other sites
http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles

##### Share on other sites
What do you need Euler angles for? Couldn't you instead just convert the quaternion directly to whatever form you need (e.g. a matrix)?

##### 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.

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

##### Share on other sites
Quote:
 Original post by StarnickBringing 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 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 on other sites
Quote:
 Original post by StarnickWe'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 'ringing the rotations into 4D space helps prevent this' was a bit misleading and potentially confusing).

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013741
×