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
    Senior Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    763

    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

Similar Threads

  1. 3D math lib
    By glnoob_andre in forum OpenGL: General
    Replies: 3
    Last Post: 02-06-2012, 12:15 PM
  2. Hi... About 3d math...
    By Magneto3D in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 11-10-2002, 07:32 AM
  3. Math help
    By el_flipis in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 05-28-2002, 03:57 AM
  4. Math
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 07-10-2001, 10:16 PM
  5. Help! What math do I need to do 3D ?
    By imported_newbie in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 10-11-2000, 08:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean