11

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?

Joseph Astrahan
  • 8,659
  • 12
  • 83
  • 154

3 Answers3

8

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.

Invalid
  • 1,870
  • 1
  • 16
  • 22
  • Actually it says `||(x,y,z)||=1`, but, apparently, your browser isn't MathML-capable. – Ruslan Dec 27 '17 at 14:20
  • ```x y z = 1 (if not, the GL will normalize this vector).``` If so, can you explain why the function is expecting a float in `glrotatef()` and a double in `glrotated()`? – Suvin Nimnaka Sukka Aug 24 '20 at 13:42
1

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.

Ruslan
  • 18,162
  • 8
  • 67
  • 136
0

glRotate means you can rotate current matrix by a given vector (x, y, z) for angle degrees. so the params x, y, z is only 3 basic params of a vector(line) in 3D space. As you can see, a vector has direction and length, but in this function, length is useless, so whether your vector length is 1 or 100 or 0.2, it doesn't make sense in this function. It's just a direction mark.