Hello,

I have recently been reading about quaternions and was wondering if it is possible to create a system which allows you to create a twist system which doesn’t flip at +/-180 and allows for 360 degree twisting?

Every test I’ve done keeps coming back to calculating an angle between two vectors which always gives you an angle between 0 and 180.

If you’re unsure of exactly what I’m looking for then this video from Jorn-Harald Paulsen should make it clear, I’d like to do it with quaternions but I’m not sure what method he uses.

I’ve read Felix Joleanes’ article on his website about preventing flipping, he has a section dedicated to a twist setup, but it’s more like an aim/lookAt constraint and this setup wouldn’t work for distributing twist along for multiple joints. It’s also depends on using some tricks/hacks with Euler angles which I would rather avoid in favour of quaternions.

Any help will be greatly appreciated!

Thanks,

-Harry

1 Like

It should not be impossible, but quaternions encode an orientation, not a rotation: there’s no equivalent in quaternion-land to a something like EulerAngles(0,0,720). Also the usual quaternion interpolation method is degenerate at 180 degrees, since there is no ‘shortest’ path across the surface of a sphere between to points at opposite poles; this makes it hard to provide a stable and consistent behavior that works for all possible poses instantaneously. However if you can provide a stable base (using quaternions or other techniques) it’s not hard to add a child transform with a single-axis Euler behavior to handle ‘winding’ beyond 180.

In general the two main approaches to fixing flips are:

(a) add history, which keeps the behavior smooth over time but can produce different results in identical poses if you get there by different routes (which may or may not be what you want). The good thing about history based solutions is that you can add things like slackness by tuning the rate of change over time. The bad thing is the history dependency, which is tricky to rig around and often needs a ‘reset’ before playback. This is basically how maya no-flip constraints work.

(b) add extra information to the vector solution which smoothly avoids degenerate cases. This is basically just a pole vector IK with some logic applied to the position of the pole vector: the movement of the ‘pole vector’ provides a hopefully flip-free basis. The trick here is to provide a predictable ‘pole vector’ behavior that won’t introduce surprises. Unfortunately there’s no obvious solution that works equally well for all setups : just like IK pole vectors, some things work well for typical leg behaviors and some for arms, but not many do equally well at both.

Hi Theodox,

Thanks for the response, do you know of any resources where I could learn more about the approaches you suggested?

-Harry