Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

rileyriley

D3DXQuaternionRotationYawPitchRoll, gimbal lock, and you.

This topic is 6021 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

And me, rather. I''m using the function in question to rotate an object in my screen given 3 euler angles (yaw, pitch, and roll were what I was going for) but I still get gimbal lock. I know quaternions are an easy-ish way to get around gimbal lock.. but using this function is giving me the exact same results I''d get by rotating around the X, Y, and Z axes with matrices. I''m aiming for subsequent rotations around the local axes of the object, but getting rotations around the world axes. Has anyone here done what I''m trying to do, and can anyone help me? Thanks in advance. ----- Riley Lark "Drinking more Dr. Pepper before 9 AM than most people drink by 9:30."

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You need to provide more information, really. But here''s the thing: it sounds like you are trying to take a rotation, represented as 3 Euler angles; then turn that into a quaternion; then rotate your object with the quaternion.

This won''t do you any good, you''ll get gimbal lock like you''re saying. Why? Because you''re still using Euler angles.

There is nothing magic about using a quaternion to rotate an object... the math comes out the same whether you use a quaternion, rotation matrix, or Euler angles. So if you start out with Euler angles, then convert to a quaternion, then rotate your object, that''s the same as if you just rotated it with Euler angles.

In order to take advantage of quaternions, they need to be the basic way that you talk about rotations. Here is what I recommend:

* Think about your rotations as occuring around one axis, and rotating the object by a certain angle.

* Look up the function for axis/angle-to-quaternion, and use that.

* Use the resulting quaternion to rotate your object.

All rotations in 3-space can be represented by one axis and angle; it''s a much better way to visualize what''s going on with your object.

I talk about this a little bit in the next issue of Game Developer, but the bitchin quaternion article is actually not until the month after that.

-Jonathan.

Share this post


Link to post
Share on other sites
Thanks for your help - I was misunderstanding what quaternions did. I had been under the impression that a rotation stored as a quaternion, when multiplied with another, effectively gave a resultant quaternion which was performed on local (already transformed) axes.

What I''m trying to do is make it so that the player of my game, controlling a space ship, can be assured that hitting the left button will make his ship turn left, around the axis going straight up through him, rather than rolling around the axis going straight up through the world. Now, you said I could use an axis-angle representation.. but how would I go about figuring out what that representation was for a particular rotation of the ship?

Example: I have the quaternion representing the ship''s current rotation. Now I want to turn the ship left (relative to itself, of course). What would I do to find the axis that I should rotate around? I really don''t have an intuitive grasp of the math behind quaternions yet.. Would I extract the axis information from the current quaternion, figure out what axis I want to rotate around relative to that reference axis, compute a new quaternion with that new axis and the degree I''d like to rotate around it by, and then multiply that new quaternion with the old quaternion?

Erf... I know this isn''t terribly clear, but I''ve been struggling with this for some weeks now. Thanks for any more help (thanks for the help already given too).

-----
Riley Lark
"Drinking more Dr. Pepper before 9 AM than most people drink by 9:30."

Share this post


Link to post
Share on other sites

  • 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!