3D Rotation which is correct

1. Dec 4, 2007

IMK

Hello,
I and just getting to grips with basic 3D rotation and have come across two nice examples, however they are different when calculating the Y axis rotation and I was wondering why and which is correct ? Or are they both correct for some convention I have mist?
Many thank IMK

1:
Yout = Yin;
Xout = Xin * cos(Theta) - Zin * sin(Theta)
Zout = Zin * cos(Theta) + Xin * sin(Theta)

2:
Yout = Yin;
Xout = Zin * sin(Theta) + Xin * cos(Theta)
Zout = Zin * cos(Theta) - Xin * sin(Theta)

2. Dec 4, 2007

Mute

Both are correct, they just rotate about the y axis in different directions (one clockwise, the other counterclockwise).

Do you know any linear algebra? It's much clearer to see these things when written out in matrix form - each rotation is described by a rotation matrix, and when you multiply the two rotation matrices together you get the identity matrix. What this tells you is that one rotation cancels out the other, so they must be rotations in opposite directions.

3. Dec 4, 2007

D H

Staff Emeritus
IMK, could you show where you found those two examples?

4. Dec 4, 2007

IMK

Mute, many many thanks for your reply as every little input helps me a great deal as my maths is both poor and rusty.

So good to know these are both correct and I guess I can use the one that fits my problem. Question does the same rule apply to the rotation about the X and Z axis that I can simply swap the cos sin +- around to control the direct? Or is there some lurking monster?

Are far as the linear algebra well I read and learn more every day but I must admit I am REALLY STUCK as far as rotation matrixes are concerned. As I have searched the web for days to find a simple (software (C if possible)) implementation of them. As all the code I can find has been written for computer graphics and does view rotation, camera and lighting etc and is much to complicated and hence confusing as all I want to do is to rotate some force vectors.

So if you happen to know of a simple C implement of a rotation matrix then I would be doing double backward summersaults.

Again many thanks for you input IMK

5. Dec 4, 2007

IMK

http://www.siggraph.org/education/materials/HyperGraph/modeling/mod_tran/3drota.htm
http://forums.sagamedev.com/topic.aspx?topicid=308 [Broken]

If you find a simple matrix implementation for rotation only, no graphics project etc etc.. Then please let me know..
Of out for dinner now but will be back about 2230 uk time..

Many tahnks IMK

Last edited by a moderator: May 3, 2017
6. Dec 4, 2007

D H

Staff Emeritus
and from another thread,

Did you read https://www.physicsforums.com/showthread.php?p=1526764#post1526764"? You are guilty here of using rotate and transform as synonyms. There are not. They are conjugates. Those force vectors you want to "rotate" are real things. You do not want to rotate them; you want to transform them from one frame to another. The frames are rotated with respect to each other. Vector representations are transformed between frames. Rotation and transformation are conjugates, which is why you have conjugate representations of the pitch matrix in your OP in this thread.

Last edited by a moderator: Apr 23, 2017