Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: glRotatef function

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    23

    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. Y-axis.
    I can find the in-between 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?

  2. #2
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,136
    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 Y-axis, 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 Y-axis => glRotatef(alpha, 0, 1, 0). But for which angle, it is not defined by the question. So, this assumption is probably wrong.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    23
    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?

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jun 2010
    Posts
    162
    Could you let me know how to find out the corrsponding rotation matrix in this case?

  5. #5
    Junior Member Regular Contributor
    Join Date
    Jun 2010
    Posts
    162
    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 = (ux, uy, uz), where ux2 + uy2 + uz2 = 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
  •