
glRotatef function
I need some clarification about glRotatef function. I have a rectangular plane with normal ax + by + cz = 0;
I would like to rotate it along (0, 1, 0) i.e. Yaxis.
I can find the inbetween angle by dot product. Suppose the angle is theta in degree. Now how can I use glRotatef function to rotate the plane so that the new normal to the plane is along (0, 1, 0) vector; Is the following ok?
glRotatef(  theta, a, b, c);
If not, what will be the correct version?

Senior Member
OpenGL Pro
That is not correct. It is not quite clear what you want to achieve.
1. If you want to make plane's normal to be coincident with Yaxis, then you need to find axis around which you have to rotate a plane. The angle is correct. It can be calculated from the scalar product. The axis, or to be more precise, the vector of rotation can be calculated from vector product: (nx, ny, nz) = (a,b,c) x (0,1,0).
=> glRotatef(teta, nx, ny, nz)
2. If the rotation should be done around Yaxis => glRotatef(alpha, 0, 1, 0). But for which angle, it is not defined by the question. So, this assumption is probably wrong.

Thank you. The first one is what I asked. But whether it would be glRotatef( theta, nx, ny, nz) or glRotatef( +theta, nx, ny, nz) . Could you explain a bit?

Junior Member
Regular Contributor
Could you let me know how to find out the corrsponding rotation matrix in this case?

Junior Member
Regular Contributor
I found the following link helpful:
http://en.wikipedia.org/wiki/Rotation_matrix
Rotation matrix from axis and angleFor some applications, it is helpful to be able to make a rotation with a given axis. Given a unit vector u = (u_{x}, u_{y}, u_{z}), where u_{x}^{2} + u_{y}^{2} + u_{z}^{2} = 1, the matrix for a rotation by an angle of θ about an axis in the direction of u is
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules