Contents / Previous / Next


Rotate

void glRotate{fd}( TYPE angle, TYPE x, TYPE y, TYPE z )
glRotate computes a matrix that performs a counterclockwise rotation of angle degrees about the vector from the origin through the point (x, y, z).


The call glRotate*(a, x, y, z) generates R as follows.

Let v = (x, y, z)T, and u = v/||v|| = (x', y', z').

Also let


Then


The R matrix is always defined. If x=y=z=0, then R is the identity matrix. You can obtain the inverse of R, R-1, by substituting -a for a, or by transposition.



The glRotate*() command generates a matrix for rotation about an arbitrary axis.

Often, you are rotating about one of the coordinate axes; the corresponding matrices are as follows.


As before, the inverses are obtained by transposition.