• Advertisement
Sign in to follow this  

Quaternion rotation VS Euler angles based rotation

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

Hi there,

If I use quaternion to rotate an object in my 3d space, I won't have any gimbal lock right?

I know about the efficiency around calculation (multiplications only and no trigo, less memory for storage etc) but wanted to be sure about the lock.

Especially, I'm calculating azimuth and elevation using the coordinates X & Z of the resulting vector of translation+rotation to camera space.
The atan2 have singularities and I wanted to know if I used quaternion I would "override" these singularities.

My maths seem rusty..
Any help would be appreciate

Share this post

Link to post
Share on other sites
Hi Radikalizm,
I understood it like that too.
It is the way to avoid it..

I read this : http://www.gamedev.net/page/resources/_/technical/math-and-physics/quaternion-powers-r1095

In the Demo Avoiding Gimbal Lock section, I read this:

[quote][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left]he main point you should take note (in the while loop) is[/left][/size][/font][/color][list]
[*]The orientation of the camera is a quaternion.
[*]There are 3 angles corresponding to the keypress. Note the angles are meant to be an on/off switch (not accumulative). I reset them inside the while loop. Of course this is not the best way to do it but as I said, it is a quick job.
[*]I convert the 3 angles to a temporary quaternion.
[*]I multiply the temporary quaternion to the camera quaternion to obtain the combined orientation. Note the order of multiplication.
[*]The camera rotation is then converted to the Axis Angle representation for transforming the final matrix.
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left]When a key is pressed, I generate a temporary quaternion corresponding to the key for a small rotation in that particular axis. I then multiply the temporary quaternion into the camera quaternion. This concatenation of rotations in 4D space will avoid gimbal lock. Try it and see for yourself.[/left][/size][/font][/color][/quote]

In my system (based on OpenGL in Max6 framework), I'm grabbing the cam quaternion and this is that one I convert to matrix and I apply it to all my objects coordinates.
This is that resulting vector I'm taking for my atan2 based azimuth calculation.

I don't use the temporary vector at all. Maybe my problem comes from here.
I don't use it because my system provides me directly the quaternion from the cam.

still stuck ?!

Share this post

Link to post
Share on other sites
[quote]I multiply the temporary quaternion to the camera quaternion to obtain the combined orientation.[/quote]
That's the key to avoiding gimbal lock. You need to have some representation of the current attitude and modify it with incremental rotations around the axes. Whether you use quaternions or some other representation is secondary.

If you keep track of a cumulative roll, pitch and yaw and then compose them into an overall rotation, you'll run into gimbal lock regardless of what representation you use.

Share this post

Link to post
Share on other sites
I got it.
and this is directly related to my mistake!

I'm using Max6 and I have to implement that.
I guess all objects required already exist but I'm a bit confuse with these [i]incremental rotations[/i]
(reference post to Max6 forum in order to excite search engines a bit :P http://cycling74.com/forums/topic.php?id=40633&replies=12#post-197452 )

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement