-
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.
-
Advanced Member
Frequent Contributor
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
-
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
-
Forum Rules