Advertisement

Gimbal Lock Strikes Again!!

Started by September 27, 2000 07:08 AM
4 comments, last by TheLabRat 24 years, 1 month ago
Does anyone know an easier way to solve gimbal lock rotation problems than with quaternions? I don''t like matrices too much - I suppose that makes me a loser in the world of 3D graphics but there it is. Please help, it is really frustrating to create an awesome 3D scene only to have you can''t look around it like a real person can. Real heads don''t roll! Thanks alot. Hehe - how about some tutorials on matrix math and depth sorting of polygons?
Matrices and quaternions are the only practical ways I know of. They aren''t so complicated after all, after you understand them.

-Jussi
Advertisement
yes matrices are the only way. though if you''re doing a 3d world seen from a first persons viewpoint u can get by with just 2 angles just do them in the same way each time
glTranslate(..) to the right place
glRotatef(heading,0,1,0);
glRotatef(pitch,1,0,0);

You could use vectors to rotate...
Someone gave me this equation, and I must confess I haven''t tried it...yet

    // Rotate dAngle Degrees (radians) Around Normalconst CVector inline Rotate(double dAngle, CVector& Normal) const{ const double dCos = cos(dAngle);const double dSin = sin(dAngle);return CVector(*this * dCos +((Normal * *this) * (1.0 - dCos)) * Normal +(*this ^ Normal) * dSin);}    

copy from CVector class

Thanks guys - will give it a go - but the glRotate commands anre what is giving me the problem - does the order with which you rotate around the axes matter (X,Y,Z / Y, X,Z etc.)?
Yes, the order of rotation matters...

For my 1st person camera, I go:
glRotate(pitchAngle, 1.0, 0.0, 0.0);
glRotate(yawAngle, 0.0, 1.0, 0.0);
glTranslatef( viewerX, viewerY, -viewerZ);

(i negate the z to counter the right-hand coord system... don''t know why... just a habit i got into )

... but when I am moving any other object around, the order of those commands is reversed (ie, translate, rotate Z, rotate Y, rotate X)

Rotations are way fun *evil smirk*

------------------------------------------------------
"You need a weapon. Look around you... can you construct some sort of rudimentary lathe?"
- Guy Fleegman, Security Officer, NSEA Protector

This topic is closed to new replies.

Advertisement