Jump to content
  • Advertisement
Sign in to follow this  
SmartyShark

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by SmartyShark
Nobody 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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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;
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!