GlRotatef
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
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 );
BTW, you only need to put a 1 for each axis
ex: glRotatef( 12.0f, 1.0f, 1.0f, 0.0f );
Quote:Original post by SmartySharkUm...it's only been 20 minutes! :)
Nobody can help me???
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.
Thank you very much for reply,
So what would represent this called function :
glRotate(12.0, 12.0, 12.0, 0.0); ?????
Greets
SmartyShark
So what would represent this called function :
glRotate(12.0, 12.0, 12.0, 0.0); ?????
Greets
SmartyShark
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)
??
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)
??
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)
??
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)
??
"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;
mat1.RotateAboutXAxis (12.0);
mat2.RotateAboutYAxis (12.0);
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.
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;
mat1.RotateAboutXAxis (12.0);
mat2.RotateAboutYAxis (12.0);
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.
Quote:Original post by SmartyShark
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)
??
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.
Go to www.opengl.org and download the spec.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement