Stupid question on glRotatef

Hi,

OK I have a question which I’m sure has a simple answer, but I don’t know what it is!

Can someone please tell me what the difference is between using:

gl.glRotatef(45.0f,0.0f,0.0f,1.0f);

and

gl.glRotatef(45.0f,0.0f,0.0f,0.5f);

Because no matter which one I use, it still rotates my object by exactly the same angle! In fact, no matter what I put for the Z value (unless it’s zero), it always has exactly the same effect.

Can someone plese enlighten me?!

And also, if there’s a reason for using one instead of the other, can anyone give me an example of where you might use it?

Many thanks!! :slight_smile:

Danny G

glRotate* (angle, x,y,z) rotates about angle degrees around the axis defined by (x,y,z).
So what’s the difference between the axis (0,0,1) and (0,0,100000000000) ? None.

The glRotate function takes a number of degrees and the last 3 parameters define a vector to rotate about.

This vector is internally normalized so no matter what you pass as z, as long as it’s a positive value you’re defining a vector that points out of the screen.

For this reason the vector (0,0,.5) is the same exact vector as (0,0,1) as far as OpenGL is concerned when it comes to rotation.

Ah, I get it now. It’s a vector in the same way that a normal is a vector to a face…? So it has a value between 0.0 to 1.0, and whichever direction the vector points in, this is the axis around which it rotates. I think!

I’ll have another play around with it anyway, and see if it makes sense. :smiley:

Many thanks!!

Danny G