Jump to content
  • Advertisement

Archived

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

safe_gaz

3D Rotation

This topic is 5602 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 was just wondering if anyone can help. This is how my rotation works. I have a set of 3D points which represent a 3D line in a graph. I have 3 variables xAngle, yAngle and zAngle. I have 6 buttons 2 of which increment and decrement xAngle by 10 and the same for the other 2. Each time a button is pressed it uses the standard rotation matrices to rotate the current positions by 10 or -10. However, if I do something like :- rotate X by 10 rotate Y by 10 rotate X by -10 rotate Y by -10 It does not not go back to the original position. Can anyone tell me why it doesnt go back to the original position and what the solution is? Thx in advance

Share this post


Link to post
Share on other sites
Advertisement
There is a ''phenomenon'' called Gimbal Lock which can occur when you use Euler angles to rotate things. Basically I think it goes something like: you are evaluating your X axis first and then your Y, but the Y is rotating a rotated X axis . . . ahh im confusing myself. This may not be your problem , but it is very common, you can use quaternions to resolve . . . .look here: http://www.anticz.com/eularqua.htm

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
rotate X by 10
rotate Y by 10
rotate X by -10
rotate Y by -10

should be:

rotate X by 10
rotate Y by 10
rotate Y by -10
rotate X by -10

Share this post


Link to post
Share on other sites
Yeah I know that by doing it in that order that it will go back to the original but the user is in control of the rotation...they could do it in the order that I stated and it wouldnt do what they thought it would.

Share this post


Link to post
Share on other sites
The problem is that order of rotation matters. You can avoid the problem with this system:

rotate in world space
do not allow roll
-90 < pitch < 90

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just to clarify, please note that this is NOT Gimbal Lock, and quaternions will NOT solve the problem. As has been stated before, it''s simply a matter of the fact that matrix (and quaternion) multiplication is not commutative, which boils down to two key words:

Order Matters

In order to undo a series of rotations, you have to perform the reverse rotations in reverse order.

Anthony Serrano

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Forgot to add this in:

If you''re worried about the user getting confused, consider

A) Using a smaller angle increment

B) Providing some kind of recentering that just sets to rotation matrix to a known state

Anthony Serrano

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!