• Advertisement

Archived

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

GIMBAL LOCK

This topic is 5295 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

I am currently developing a simple flight sim. I have problems with gimbal lock. My aircraft is facing in negative x direction with roll using z-axis, yaw using y axis. Is there any solution beside quaterions. Because I have tried using quaternions but I ended with a crazy aircraft rotation. Any help here it would be great! Thaks Chris

Share this post


Link to post
Share on other sites
Advertisement
What do you mean by an example in OpenGL? That''s a mathematical problem, not a graphical one. So it''s not specific to OpenGL.

Quaternions usually work pretty good. Are you sure your implementation was flawless? You could go over to the Math and Physics section of Articels&Resources, there''s quite a few articles about quaternions there.
If you want to avoid using them completely, you could try searching on google, for example avoiding "gimbal lock" -quaterions. Here''s also another nice article...

Share this post


Link to post
Share on other sites
I mean a flight sim camera code example in opengl, because I am using opengl. So that it is faster to understand.

BTW the articles that you pointed out are nice, but still I cannot get it to work.



[edited by - cmangund on August 19, 2003 7:04:20 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
http://sjbaker.org/steve/omniv/eulers_are_evil.html

Share this post


Link to post
Share on other sites
Guts which tutorial did you mean? I already searched the NEHE opengl tutorial but cannot find the one you pointed out?

Share this post


Link to post
Share on other sites
quote:
Original post by guts
the last game tutorial on nehe''s ...

I know which tutorial do you mean, but where is it now?! NeheJeff had moved it? where?

for cmangund: Do not use pitch/yaw/roll, it is better to have one vertor pointing "front" and second pointing "up" the plane.
It is much faster for computing air friction, gravity etc..


...::why don''t we have assembler forum?::...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I have decided to try quaternions again. This time the ship did not turn like crazy but I still have Gimabal Lock problem.
Can anybody tell me what''s wrong with my code snippet below ?

Thanks


Quaternion qx,qy,qz,qx2,qy2,qz2;

float matrix[16],m2[16],m3[16],m4[16],m5[16],m6[16],m7[16];



qy.CreateFromAxisAngle(0, 1, 0, -xg->roty);
qx.CreateFromAxisAngle(1, 0, 0,-xg->rotx);
qz.CreateFromAxisAngle(0, 0, 1, -xg->rotz);

qy2.CreateFromAxisAngle(0, 1, 0, xg->roty);
qx2.CreateFromAxisAngle(1, 0, 0, xg->rotx);
qz2.CreateFromAxisAngle(0, 0, 1, xg->rotz);



qy.CreateMatrix(matrix);
qz.CreateMatrix(m2);
qx.CreateMatrix(m3);

qy2.CreateMatrix(m4);
qz2.CreateMatrix(m5);
qx2.CreateMatrix(m6);


glMultMatrixf(m3);

glMultMatrixf(matrix);
glMultMatrixf(m2);

glTranslatef(-(xg->posx),-(xg->posy),-(xg->posz));








glPushMatrix();


glTranslatef(xg->posx,xg->posy,xg->posz);//-30,2

glMultMatrixf(m5);

glMultMatrixf(m4);
glMultMatrixf(m6);



xg->RenderXglwing();


glPopMatrix();

Share this post


Link to post
Share on other sites
?? i dont know much about quaternions (and as long as i dont have to do a lot of interpolated rotations i just cant see any reason to use them), but where are you using them? what i see seems to convert euler angles to quats and quats to matrices, while the quats are never used for anything.

the problem isnt doing as many wild and pointless conversations as possible, but realizing that euler angles suck and storing orientation as 3 angles just cant and wont work.

Share this post


Link to post
Share on other sites
Then is there any practical solution example that I can see.
I searched the web but most of them are only theories and no real example.

Share this post


Link to post
Share on other sites
You should be multiplying the quaternions together to produce a new one (the resultant). Converting them into matrices and then multiplying them together does nothing for your gimbal lock problem.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
With or without quaternions is the basic idea to store the orientation and change it with the current rotation. This is explained in the "Eulers are evils" page a posted a link to. Here is an article describing the implementation with quaternions

http://www.gamedev.net/reference/articles/article1095.asp

From that article
1. Use a quaternion to represent the rotation.
2. Generate a temporary quaternion for the change from the current orientation to the new orientation.
3. PostMultiply the temp quaternion with the original quaternion. This results in a new orientation that combines both rotations.
4. Convert the quaternion to a matrix and use matrix multiplication as normal.

This could be done with ordinary matrices also as in the "Eulers are evils" page.

Share this post


Link to post
Share on other sites
So the mutiplication must be done in quaternion form not in matrix form. After you get the resultant quaternion you change it back to matrix form. Ok I will try. Thanks all. If there is another problem I will post again.

Share this post


Link to post
Share on other sites
quote:
Original post by cmangund
So the mutiplication must be done in quaternion form not in matrix form. After you get the resultant quaternion you change it back to matrix form. Ok I will try. Thanks all. If there is another problem I will post again.


you should read it again, especially his last line. it doesnt matter if you mult quats or matrices. the only reason for quats is that its less math. as far as i understand a quat is representing exactly the same as a 3x3 rotation matrix, just in a different way.

the problem is that you cant just add up a few angles when you rotate, not if you use/mult quaternions or matrices. the problem is euler angles, nothing else.

Share this post


Link to post
Share on other sites

  • Advertisement