#### Archived

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

# 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.

## 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 on other sites
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

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 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 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 on other sites
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 on other sites

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

1. 1
2. 2
3. 3
Rutin
24
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631766
• Total Posts
3002232
×