Jump to content
  • Advertisement
Sign in to follow this  
kburkhart84

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.

If you intended to correct an error in the post then please contact us.

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


Link to post
Share on other sites
Advertisement
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!