Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 667
Joseph Astrahan Avatar asked Oct 03 '13 23:10

Joseph Astrahan


2 Answers

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.

like image 147
Invalid Avatar answered Nov 08 '22 01:11

Invalid


It doesn't say that x, y and z are vectors. If you open the page with a MathML-capable browser, you'll see something like

glRotate produces a rotation of angle degrees around the vector (x,y,z).

I.e. x, y, z are components of a single vector. Similarly, it doesn't say "x y z = 1 (if not, the GL will normalize this vector)": instead, it says:

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

So, (x,y,z) is the vector, rotation around which the function will produce. If the vector you supply is not normalized, the GL will normalize it, so glRotate(2,0.5,0,0) and glRotate(2,0.0174524,0,0) are equivalent.

like image 34
Ruslan Avatar answered Nov 08 '22 03:11

Ruslan