Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Viper173

gimbal lock (again...)

This topic is 5232 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Just when I thought I had solved the problem a new one comes along... here''s what I implemented : ///////////////////////////////////////////// glPushMatrix; glLoadIdentity; key_quat := Euler2Q(key_x, key_y, key_z); temp_quat := Obj_quat; Obj_quat := Q_MultN(temp_quat, key_quat); GetAxisAngle(Obj_quat, angle, axis); angle := (angle*180/Pi); glRotatef(angle, axis[1], axis[2], axis[3]); glGetFloatv(GL_MODELVIEW_MATRIX, @Model_Matrices); glPopMatrix; glMultMatrixf(@Model_Matrices); DrawModel; /////////////////////////////////////////// and here''s what happens: The model rotates just fine about its local coordinate system. But after a couple of random rotations the orientation of the model and its euler angels dont match up. (if you dont understand: In my processKeys function I wrote this Key_x := 0; if DownKeyPressed Begin ModelX := ModelX + 1; Key_X := +1; End; So ModelX keeps track of the overall rotation angle. But after numerous rotations 90 degrees ain''t exactly 90 degrees anymore) It seem like a roundoff error to me. But with floats? Assuming the functions are correct, What did I do wrong??? please help.

Share this post


Link to post
Share on other sites
Advertisement
I always hate it when forum goers ask ''Why are you ____?''.

That said, why are you building a quaternion from Euler Angles? Shouldn''t you use the Euler Angles in an Axis-Angle to build quaternion rotations (thus instantly rotating around object-space)? I see you are using Axis-Angle for something, it gets kind of hard (for me) to follow.

I''d wager if you''re having problems it is because of the Euler to Quaternion Building that happens when this function is called.

Do your Euler values ''build up'' from cycle to cycle, or do they get rebuilt ever time the function is called? In my own program I zero them out (though I do use Axis-Angle, rather than strict Euler - Euler rotations are always about the ''identity'' and not the local coords) after they''ve been piled in to the quaternion rotation. I used to keep them and just rebuild the quaternion, but the rotation would fritz out at higher euler values. Now the values never get that high and the program doesn''t wig out.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!