Sign in to follow this  
kburkhart84

quaternion help

Recommended Posts

kburkhart84    3187
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 this post


Link to post
Share on other sites
SiCrane    11839
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 this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by kburkhart84
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.


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.

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