# www.jpct.net

## jPCT - a 3d engine for Java => Bugs => Topic started by: Emmanuel on June 30, 2013, 10:10:22 pm

Title: Matrix.rotateX rotates clockwise
Post by: Emmanuel on June 30, 2013, 10:10:22 pm
Hello,

Thanks for your work. I think I might have encountered a misleading method description. Indeed the doc says rotateX creates a counter-clockwise rotation for positive angles but it appears to create a clockwise rotation matrix.

How you can test:
Code: [Select]
`Matrix mat = new Matrix();mat.rotateX((float)Math.PI/2);Logger.Log(mat.ToString());`
You get the matrix:
1  0  0  0
0  0  -1 0
0  1  0  0
0  0  0  1
Which sends (0  1  0  0) to (0  0  -1  0). (I'm assuming row vectors)
Which corresponds to clockwise
Title: Re: Matrix.rotateX rotates clockwise
Post by: EgonOlsen on June 30, 2013, 10:20:34 pm
I think you are right. I'll change the docs for the next release.
Title: Re: Matrix.rotateX rotates clockwise
Post by: Emmanuel on July 01, 2013, 11:12:37 am
Thanks for the quick response.

BTW, I believe rotateY and rotateZ also have the same problem.
Title: Re: Matrix.rotateX rotates clockwise
Post by: EgonOlsen on July 04, 2013, 08:58:17 pm
Thinking about this again, i think that the docs are correct. (0  1  0  0) to (0  0  -1  0) means that a vector pointing down now points to the front which is, when viewed along the x-axis, a counter clockwise rotation, isn't it?
Title: Re: Matrix.rotateX rotates clockwise
Post by: Emmanuel on July 08, 2013, 11:14:19 am
I have to disagree going from (0 1 0 0) to (0 0 -1 0) is clockwise. (I am "looking" from positive X)
Title: Re: Matrix.rotateX rotates clockwise
Post by: EgonOlsen on July 08, 2013, 12:13:52 pm
"From positive X" means that you are looking at the origin from some x-value? If that's the case, i would say that you are looking into the wrong direction... ???
Title: Re: Matrix.rotateX rotates clockwise
Post by: Emmanuel on July 08, 2013, 12:31:46 pm
Yes I am looking at the origin from a positive X value because rotation axis is positive X
Title: Re: Matrix.rotateX rotates clockwise
Post by: EgonOlsen on July 08, 2013, 12:46:49 pm
I'm not sure if there is an "official" way of looking along axes, but to me, this is the wrong direction. To me, that's like saying that my left hand is actually my right one, because somebody who is looking at me sees it that way. However, i can add this little detail to the docs and we both should be happy...!?
Title: Re: Matrix.rotateX rotates clockwise
Post by: Emmanuel on July 08, 2013, 03:00:24 pm
Ok thanks a lot.
You might want to know there is a mathematical convention. ANYWAY
If everybody likes it that way its great
Love the engine, just wanted to help.
Thanks again