Notifications
Clear all

[Closed] Meditations on Gimble Lock

So 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?

8 Replies

How are you converting to Euler?

-Eric

QuatToEuler

What are converting? QuatToEuler $.rotation or $.rotation.controller.value? Also, have you tried quatArrayToEulerArray?

quatArrayToEulerArray <quat array> [left]Returns an array of smooth Euler values from the quat array. Available in 3ds Max 2008 and higher. Previously available in the [AVG ] 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 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)
[/left]

That fixed it. Thanks! Is QuatToEuler2 better or is it just going to go bananas in a different esoteric rare situation?

QuatToEuler2 supposedly returns the same values as viewed in the Transform Type-In areas of the UI.

quatToEuler2 <quat> [left]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 ] Avguard Extensions.
-Eric
[/left]

Thanks PixelMonkey for helping us figure that out

No problem, where do I send the bill?

-Eric

Definitely to Mike.