Jasonb

04-26-2000, 04:44 PM

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.

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

Jasonb

04-27-2000, 04:14 PM

Thanks, ill give it a go asap

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.