# GlRotatef

This topic is 4031 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello there, i have following question: I call this following function: glRotatef(12.0, 12.0, 12.0, 0.0); // 12 degrees for x- and y-Axis Can somebody tell me how the upper called function would look like in the modelview matrix and in code ????? I mean something like this: glRotatef(12.0, 0.0, 12.0, 0.0); // WRONG! glRotatef(12.0, 12.0, 0.0, 0.0); // WRONG! This is not the same like above. Why ??? M = Rx(12 Grad) * Ry(12 Grad) // This is wrong too, i know I would be very thankful if somebody could help me.... Gruss SmartyShark

##### Share on other sites
Nobody can help me???

##### Share on other sites
I don't understand what you're asking.

BTW, you only need to put a 1 for each axis
ex: glRotatef( 12.0f, 1.0f, 1.0f, 0.0f );

##### Share on other sites
Quote:
 Original post by SmartySharkNobody can help me???
Um...it's only been 20 minutes! :)

Anyway:
glRotatef(12.0, 12.0, 12.0, 0.0); // 12 degrees for x- and y-Axis
This does not represent a 12 degree rotation about the x and y axes, but rather a rotation about an axis that lies along the diagonal of the positive quadrant of the xy plane. As such, the two code excerpts you posted will not produce the same results.

##### Share on other sites
Thank you very much for reply,

So what would represent this called function :

glRotate(12.0, 12.0, 12.0, 0.0); ?????

Greets
SmartyShark

##### Share on other sites
I mean in one by one steps like :

glRotate(12.0, 1.0, 0.0, 0.0) etc.

Which code would as an alternative represent this:

glRotate(12.0, 12.0, 12.0, 0.0)

??

##### Share on other sites
I mean in one by one steps like :

glRotate(12.0, 1.0, 0.0, 0.0) etc.

Which code would as an alternative represent this:

glRotate(12.0, 12.0, 12.0, 0.0)

??

##### Share on other sites

can nobody help me??

##### Share on other sites
"glRotate(12.0, 12.0, 12.0, 0.0)"

If I understand well what you wanna do, you just want to make a first rotation of 12 degrees along the x axis, and then a second rotation of 12 degrees along the y axis.

Just make that :

glRotatef (12.0, 1.0, 0.0, 0.0); // First rotation about the X axis
glRotatef (12.0, 0.0, 1.0, 0.0); // Second rotation about the Y axis

And, of course, it's not the same as :

glRotatef (12.0, 0.0, 1.0, 0.0);
glRotatef (12.0, 1.0, 0.0, 0.0);

If you wanna make those rotations by yourself, just create two matrices :

Matrix4 mat1, mat2, matFinal;
matFinal = mat1 * mat2;

glMultMatrix (&matFinal.m00);

It's exactly the same as using glRotatef, since glRotatef affects the modelview matrix.

Said you make glRotatef (12.0, 1.0, 0.0, 0.0), internally, OpenGL creates a rotation matrix along X axis :

1.0 0.0 0.0 0.0;
0.0 cAngle -sAngle 0.0
0.0 sAngle cAngle 0.0;
0.0 0.0 0.0 1.0

with cAngle is the cosine of the angle in radians, and sAngle the sinus of the angle in radians.

And then multiplies this matrix with the modelview matrix.

And with your own functions :
Matrix4 mat1;
mat1.RotationAboutXAxis (12.0), it creates a matrix, and with the function glMultMatrix (&mat1.m00), you multiplies the modelview matrix with that matrix.

Hope I didn't say to much false things, since I never learned matrices at school, just with books, alone :p.

##### Share on other sites
Quote:
 Original post by SmartySharkI mean in one by one steps like :glRotate(12.0, 1.0, 0.0, 0.0) etc.Which code would as an alternative represent this:glRotate(12.0, 12.0, 12.0, 0.0)??

Why do you put 12.0 for the vector part? Yes, GL normalizes the vector but it looks like you are experimenting and just throwing numbers at GL.
This kind of stuff is explained in the GL spec in case you are interested in long technical documents.

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

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

• Total Topics
631766
• Total Posts
3002237
×