glRotate(angle,x,y,z), what is x,y,z in this case?

Joseph Astrahan picture Joseph Astrahan · Oct 4, 2013 · Viewed 17.2k times · Source

I've read the documentation here: http://www.opengl.org/sdk/docs/man2/xhtml/glRotate.xml

It specifies that angle is in degrees. It says that X,Y,Z are vectors. If I say glRotate(2,1,0,0) that says I will rotate 2 degrees about the X axis.

What happens if I say glRotate(2,0.5,0,0) and glRotate(2,0.0174524,0,0)

I don't understand what's really happening in that situation, can someone help explain to me?

Does it rotate as a percentage of the angle?

Answer

Invalid picture Invalid · Oct 4, 2013

It will still rotate 2 degrees about the X axis. That page you linked also says the following:

x y z = 1 (if not, the GL will normalize this vector).

Meaning the vector (x,y,z) is a unit vector (of length 1), and if it's not, GL will normalize the vector (dividing it by its length, making it of length 1).

Conclusion: the x,y and z parameters define a vector, of which the direction is the only relevant part, the length will be dealt with by the function. Thus you can safely put in any vector and it will simply rotate about that vector.