# quaternion help

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

## Recommended Posts

I know y'all have seen this type of question before. I searched the forums from before and couldn't find my answer. I'm trying to rotate a model in OpenGL using quaternions instead of matrices or just straight angles. As of now, I have a rotation quaternion, but what operation do I do with it to get a rotation about X or y or z axis? I have a quaternion class with basic operations, but I'm not sure if it is multiplication or exactly how to go about getting the rotation to work. I want it to work like in descent where the rotation goies about the current local coord system, not the global, but I want to convert the local coord to the global coord(Euler angles) in order to draw the model, and calculate it's movement vector.

##### Share on other sites
Let's say you have a unit vector that you want to do a rotation around, call it V. You can create the quaternion that performs rotations about V by an angle theta by q = ( c, sV ) where s is equal to sin(theta/2) and c is equal to cos(theta/2). So if you want to perform a rotation about the x-axis, you would use a V equal to (1, 0, 0).

To rotate a vector P (x, y, z) with the unit quaternion q, you would create a pure quaternion out of P, call it p = xi + yj + zk. Then the rotation of P by q would be defined by q p q*

[Edited by - SiCrane on July 6, 2004 2:12:12 PM]

##### Share on other sites
Quote:
 Original post by kburkhart84I know y'all have seen this type of question before. I searched the forums from before and couldn't find my answer.I'm trying to rotate a model in OpenGL using quaternions instead of matrices or just straight angles. As of now, I have a rotation quaternion, but what operation do I do with it to get a rotation about X or y or z axis? I have a quaternion class with basic operations, but I'm not sure if it is multiplication or exactly how to go about getting the rotation to work. I want it to work like in descent where the rotation goies about the current local coord system, not the global, but I want to convert the local coord to the global coord(Euler angles) in order to draw the model, and calculate it's movement vector.

Do you have a good reason to use quaternions in the first place!? Not using a matrix aint' one of them because you do have to convert to a matrix form after all your rotations have happened. You should understand your problem more thouroughly before blindly jumping to something new. Get a book that explains that type of shit like "Mathematics for Game Developers" or "3D Math Primer for Graphics and Game Development", (although I wouldn't recommend the second one, for it doesn't really cover quaternions thourougly). Any general math book will do too.

• 48
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631380
• Total Posts
2999673
×