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 3 of 3

Thread: Math behind gluLookAt

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2000
    Posts
    12

    Math behind gluLookAt

    Does anyone know how to convert a forward vector from the camera to angles?

    By that i mean, the camera is looking in the direction of a normalized vector. Instead of using gluLookAt, how can i convert this vector to angles.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    765

    Re: Math behind gluLookAt

    Project the vector to each plane and work out the angle to the axis.

    for ex. if you have the vector (1,2,3), then consider the angle of the vector (1,2) on the Z plane (ie. theta1=arctan(0.5)). this is the rotation about the y-axis.
    Similarly, projecting the vector onto the X plane gives theta2=arctan(2/3); Thus, the requried rotation is

    glRot(arctan(2/3), 1.0, 0.0, 0.0);
    glRot(arctan(0.5), 0.0, 1.0, 0.0);

    you can't recover z rotation (since it isn't specified). I hope the maths is right. ;-) but the idea should be sound: projection to recover one angle.

    Hope this helps,

    cheers,
    John

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2000
    Posts
    12

    Re: Math behind gluLookAt

    Thanks, ill give it a go asap

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •