PDA

View Full Version : Gimbal lock and direction... help me



lsdi
01-08-2002, 07:07 PM
In this code I have that gimbal lock problem,
How can I avoid gimbal lock without using quartenions?
How do I move in the same direction of camera lens?


Code:

tx=cam.x+cos(cam.yaw)*0.5;
ty=cam.y+sin(cam.pitch)*0.5;
tz=cam.z+sin(cam.yaw)*0.5;
rx=sin(cam.roll)*0.5;
ry=cos(cam.roll)*0.5;
rz=0.0;

gluLookAt(cam.x,cam.y,cam.z,
tx,ty,tz,
rx,ry,rz);

Morglum
01-09-2002, 12:56 AM
You can't avoid the gimbal lock without dealing with either quaternions or matrices - which turns out to be the same. Remember that yaw, pitch, roll angles are intrisically nonsymmetric, because they give the vertical axis a special role. The camera direction should be simply represented by the corresponding modelview matrix.

Jambolo
01-13-2002, 01:42 PM
The only way to prevent gimbal lock using Euler angles is to restrict the camera orientation, i.e. -90 < pitch < 90 and -90 < roll < 90.