View Full Version : Meditations on Gimble Lock

 thatoneguy01 January 2011, 07:35 PMSo I have an output script which collects the Quat values for an object and then I need to convert that to Euler angles. Unfortunately this is causing quite the trouble with a perfect storm of gimble lock: (quat -0.486683 0.512971 -0.486683 0.512972) (quat -0.495561 0.504399 -0.495562 0.5044) (quat -0.504289 0.495674 -0.504289 0.495674) (quat -0.512863 0.486797 -0.512863 0.486798) (quat -0.52128 0.477772 -0.521281 0.477773) (quat -0.52954 0.468602 -0.529539 0.468603) (quat -0.537637 0.459289 -0.537637 0.45929) (quat -0.54557 0.449835 -0.545571 0.449837) (quat -0.553338 0.440245 -0.553339 0.440247) (quat -0.560938 0.430522 -0.560937 0.430522) (eulerAngles 86.9872 -89.9999 0) (eulerAngles 13.2849 -89.9999 73.8355) (eulerAngles 90.9872 -89.9999 0) (eulerAngles 52.5494 -89.9999 41.5526) (eulerAngles 41.9872 -89.9999 53.9726) (eulerAngles 96.9872 -90 0) (eulerAngles 98.9872 -89.9999 0) (eulerAngles 28.393 -89.9999 74.9816) (eulerAngles 32.9052 -89.9999 72.8973) (eulerAngles 104.987 -89.9999 0) In such a scenario is there anything I can do to the Quat values to trick it into returning a nice consistent Euler Rotation?
PiXeL_MoNKeY
01 January 2011, 08:07 PM
How are you converting to Euler?

-Eric

thatoneguy
01 January 2011, 08:20 PM
QuatToEuler

PiXeL_MoNKeY
01 January 2011, 08:57 PM
What are converting? QuatToEuler \$.rotation or \$.rotation.controller.value? Also, have you tried quatArrayToEulerArray?quatArrayToEulerArray <quat array> Returns an array of smooth Euler values from the quat array. Available in 3ds Max 2008 and higher. Previously available in the [AVG (http://forums.cgsociety.org/) ] Avguard Extensions.-Eric

EDIT: it looks like quatArrayToEulerArray suffers the same problem, but using quatToEuler2 on the quats does it right. Be sure that if you do this directly from the rotation controller you do quatToEuler2 obj.rotation.controller.value, see this (http://forums.cgsociety.org/showthread.php?f=98&t=947428) thread for more info on that.

(eulerAngles 86.9872 -90 0)
(eulerAngles 88.9872 -90 0)
(eulerAngles 90.9872 -89.9802 0)
(eulerAngles 92.9872 -90 0)
(eulerAngles 94.9872 -90 0)
(eulerAngles 96.9872 -90 0)
(eulerAngles 98.9872 -89.9802 0)
(eulerAngles 100.987 -90 0)
(eulerAngles 102.987 -90 0)
(eulerAngles 104.987 -90 0)

thatoneguy
01 January 2011, 10:08 PM
That fixed it. Thanks! Is QuatToEuler2 better or is it just going to go bananas in a different esoteric rare situation? :D

PiXeL_MoNKeY
01 January 2011, 10:15 PM
QuatToEuler2 supposedly returns the same values as viewed in the Transform Type-In areas of the UI.quatToEuler2 <quat> Returns the same Euler value for the given Quaternion as shown in the Transform Type-In dialog. Available in 3ds Max 2008 and higher. Previously available in the [AVG (http://forums.cgsociety.org/) ] Avguard Extensions.-Eric

japetus
01 January 2011, 10:23 PM
Thanks PixelMonkey for helping us figure that out :)

PiXeL_MoNKeY
01 January 2011, 10:48 PM
Thanks PixelMonkey for helping us figure that out :)No problem, where do I send the bill? ;)

-Eric

thatoneguy
01 January 2011, 07:50 PM
No problem, where do I send the bill? ;)

-Eric

Definitely to Mike. :p

CGTalk Moderation
01 January 2011, 07:50 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.

1