A Quaternion Twist Solution Which Allows For 360 Degrees Of Rotation?


#1

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


#2

I actually recently had the same problem

I found a solution by using 3 vectors instead of 2.
The third vector is there to point to which side of the angle you want read.

In Maya I used the 3 point circular tool and input my vectors. Then you can get the angle from the 3pointcircularTools sweep attribute.


#3

That’s interesting. I had a play with the Three Point Circular Arc tool and when I connected the sweep attribute to an object’s rotation and then changed the angle the rotation value didn’t update…

But I think it’s given me something to start with, it’s not the elegant solution I was hoping for but if I can get it to work then I’d be happy!

Thanks,
-Harry


#4

Ah that’s right. I couldn’t get the sweep to update as well.

I just thought of a simple solution that might do the trick.

Since the angles can’t go over 180, why not use 2 angles and add them together? 2 angles with 3 vectors.

(sorry I can’t remember how to share a photo)

https://photos-1.dropbox.com/t/2/AABGH8vE0vUKi98T7KkUnNPVtWkvhbjbSJV8-V5CViraHA/12/78536340/jpeg/32x32/1/_/1/2/2%20angles.jpg/CJS9uSUgASACIAMgBCAFIAYgBygBKAI/ZDj6WzG4bkt4EjEWX-qevYBjBB5wwKCm3b7zzQYZ46c?size=1280x960&size_mode=2

Vector 2 is always centered between vectors 1 and 3
Angles A and B share vector 2.


#5

Hello,

I thought about using 3 vectors: if we have two vectors A and B then we can have C = A + B, that would give us an average direction between the two vectors meaning we had two identical angles which you might think would allow us to get 360 degrees of rotation, but the problem comes when A and B point in opposite directions then C = [0, 0, 0]

We would also still be limited to +/-180 degrees: let’s say A = [1, 0, 0], B = [0, 1, 0] -> C = [1, 1, 0] (we could normalize C but it doesn’t matter), so we have two 45 degree angles created between AC and BC but when B is rotated 180 degrees to [0, -1, 0] -> C = [1, -1, 0] and we still have two 45 degree angles instead of two 135 degree angles.

-Harry

P.S - I like your goose character on Vimeo!


#6

Ah okay I see what you’re getting at.

This is more what I had in mind.

https://www.dropbox.com/s/nzdvwp3d8s1a2ap/angle%20read%20to%20360.mp4?dl=0

I’m just using point constrained locator translations as vectors in this case.

Hopefully this’ll at least give you some new ideas or push you in the right direction!

and thanks! glad you like the goose!


#7

Hey Harry , Hey Daniel …have you looked at this :
https://vimeo.com/108727407
although im not quite sure about how he implemented this in arm set up
also excuse my ignorance : what is Point Circular Arc tool ? 3pointcircularTools sweep attribute … i just want to catch up this conversation coz this twist issue is one of my nightmares i want to overcome
N.B : for some reasons dropBox images dont show


#8

Hi Ahmed,

The 3 Point Circular Arc tool is a Maya tool in Create > Arc Tools.

I’ve seen that video before and although it looks cool and he says he parent constrains it to his arms and legs, I’m not a big fan of it. Also, using a twist deformer doesn’t solve the problem because you still have to extract an angle to drive the start and end angles.

I think I’ve come up with a way to get 360 degrees of twist, but I haven’t tried it yet, I’ll do a test this evening and post my file here later.

-Harry

EDIT: I think that Jorn-Harald’s twist extraction method still flips when rotated 90 degrees in a certain direction (if X is the twist, the Y or Z) just like a normal twist setup, I think the red control parented to the wrist in the video controls the up vector so you can avoid flipping by manually rotating it.


#9

Argh, it didn’t work: although you can manually rotate an object past 180 degrees and have an object orient constrained to it and everything work fine, you still get the same +/-180 problem if you use Maya nodes.

I’ve attached the file which has a bookmark in the Node Editor.

My method was as follows:

[ol]
[li]Start with a vector and transform it into the space “target” (“pointMatrixMult1”).
[/li][li]Multiply 1) by the inverse of “parent” (“pointMatrixMult2”), this essentially extract the vector which will now rotate around the origin.
[/li][li]Get the Y and Z components of the 2) and create a normalized vector [0, Y, Z], now this vector will rotate in the YZ-plane (“vectorProduct2”).
[/li][li]Use the vector from 3) along with the vector [1, 0, 0] (the aim vector) to create a new vector which is orthogonal to both of them (“vectorProduct1”)
[/li][li]Use the aim vector, the vector from 3) and the vector from 4) to create a 4x4 matrix (“fourByFourMatrix1”).
[/li][li]Extract the rotation from 5) and put it into an empty transform group (“orientTarget1”)
[/li][li]Use 5) in an orientConstraint and place the local space rotation of “extractedTwist” into “twistObject”.
[/li][/ol]

It just turns out like a normal setup which flips as you expect it to!

Any other suggestions?

-Harry


#10

Harry,

[If you’re using 3ds Max] Take a look at that Hybrid Spine Test Rig I posted in the Character Rigging forum a long time ago. If I recall correctly, that setup allows my spine bones to twist greater than 360 degrees without flipping… I believe the green box-shaped control objects controlled the spine twist (using parameter wiring)-- but my memory is foggy.

Good luck.


#11

Hi Michael,

The problem with your method is that it uses local space rotations which can run into gimbal locking. Also the rotation axis can be misleading, for example in your if you move the top green control, say, 40 units in the Y axis and -15 unit in the X axis while in parent space then you see that intuitively we expect the twist axis to be Y not X.

-Harry


#12

Five and a half months later: https://vimeo.com/149066264 :stuck_out_tongue:


#13

Another life-problem solved!

I have been trying to tackle this issue for several weeks now and finally came up with a new node for this.
It’s really a wonder that no one before came up with a node like this. At least from what I have found amongst free tools. I am sure that some studios have their own solution hat hand but of course that’s all proprietary. Lot’s of artists are looking for a solution/workaround though. Stuff like this should be standard in any 3D app.

https://vimeo.com/188368312

Cheers.


#14

Its good to be young…, just a little precision: ( ok already talk about it on ingo vimeo page : its my my reallly old cgtalk account…).

Extracting reliable twist over 180 degrees is impossible. you can try all day long, for years, it wont change math and physic core limitation…
As charles looker ( eek on this forum ) point out you can study Dirac quaternion belt trick / exponential map , but from my experience that wont solve anything at all ( still have a long way to go to be honest but i grow up a bit and now try to focus my energy on more important research )

Using an history is not compatible in an animation rig. it works only when you start to bake your animation or alembic mesh.
I Never was blessed to work with an animator who scrub timeline in only one direction: why would they need to ?
they need to jump in time evaluate the silhouette , rhythm motion interpolation and so on.

“It’s really a wonder that no one before came up with a node”: to be honest its a really basic node to make, done almost by anyone who study the maya API and coming from a rigging background ( i posted my open source flavour only in 2014 ( but work on this much more earlier) https://github.com/cedricB/circeCharacterWorksTools/blob/master/maya/plug-ins/tortilla.py ).

Maya architect are also well aware of this:

People also need to be aware that when you rely on a close source plugin you are tied to the author, you cannot optimize, fix thing when the break. ( heck, michael Comet open the way with his pose deformer/reader, and it still relevant nowadays ).

Another example of closed source element are the soup nodes, real masterpiece from peter shipkov and other people, really interesting to study even though it is closed source ( we are talking about procedural node extension before mash got created and bough by autodesk )


#15

The quatTwist node just has been updated to version 2 with more stability in animation.

Here’s the explanation for version 2: https://vimeo.com/190160103
And here’s some sample animation: https://vimeo.com/190007415

Yes, agreed that there cannot be a perfect solution to the subject due to several reasons. Nevertheless, all available solutions, may it be constraints, ik handles or other custom nodes have their individual strengths and weaknesses. So it’s up to the user to decide which solution is the best depending on the project.
It’s basically just throwing another option in there.

And even if it might be a good API exercise it’s still interesting to see how many people struggle to find a good solution for their needs. Not everyone is API savvy or good at scripting to begin with and those who are diving into the API often work for a studio and of course all this work is proprietary and never to be published, and thus not helpful for the general community.

And regarding open source: Yes, it’s always important to be considerate about which tools to use. But that doesn’t mean that open source is always the solution. Many people writing tools make them available as open source just because they don’t have the time to support it or they just moved on and make old stuff public but without any support. Open source often means - no support, do it yourself. If you want to use the tech you have to be able to compile for yourself and fix issues when they occur. And not many people have the means to do that or are interested in it.
Personally, I rather use a plug-in which has a good support, someone who cares about his tools, than having to fix and compile for myself.
And always remember that even larger plug-ins, for example VRay or Renderman are not always throwing out a compatible release as soon as a new Maya version is available.

Cheers.


#16

Hi Ingo thats funny to read your update, that’s pretty much what we discuss in the private email you requested on Vimeo last week.
To complete this thread I will add my point of view here as well.

@Not everyone is API savvy or good at scripting to begin with.
Im dont really agree on this one:
What we expect for most people is to learn their craft and get comfortable with their tool. At some point one element that get
important as well is start to have basic experience with scripting capacities of your software:
Here you dont need to concern yourself with python pymel nor dotnet if you have 3dsmax background.

Dont be shy and be concerned with style, naming convention and other programming issue.

Just take babies step and look at your script editor when you do an action: its fun interactive and easiy to do.

From there you can just patch some automation procedure by moving things around 
and it might be enough for you most of the time.

@Those who are diving into the API often work for a studio … their work will never be published,and thus not helpful for the general community.
Depends of place, and experience you have with contract. when you learn the api at the studio,
you build element specific to the studio so sure these are elements that give competive edege between place

One thing people have to be aware of is that a studio own only what it paid for:
what you do before enrolling and after you quit a company is yours.
What you do on your free time or at home have nothing to do as well from them:
Only what you do at their facility, using their ressource are covered by fair ip contracts.

In my case it quite clear in most of the studio i work at ( mid to small place ) i wrote more plugins for maya
than their entire pipeline tool department… and i have demoreels showing work anteriority).
So im free to share my toys as what i did in those place was trying to integrate my works following their
pipeline constraint, time/budget

My most original/ solid work where done at home because of that .
I really enjoyed working alongside different department like look dev / characteFX or animation) though.

@Open source often means - no support, do it yourself:
When you look at rigging 95 percent of things can broken ,recombined, split shared as simple scripted plugins:
Focus first on stability and reliability, speed will come later. ( and you can get some help form your
programmers or TD ).

On such a nodes having template file or short script to connect element are more than enough.

@good API exercise (ibid: that was the very own formula i used)
I was saying that writing a twist reader is an excellent beginner exercise:
It cover fundamental concept like vector math, ( projection, angle between )
[one assignment could be to rewrite from scratch maya angle between node.]

matrix space conversion:
[writing max expose transform so you can from two matrix attribute let say  extract the angle 
between both up vector]

aim constraint, and quaternion.
[( cross product, pole vector). and the use of quaternion to have a reliable reference space ].

Its kind of hands on eaxmple which can help you improve,spread your coverage of the API and gain confidence.

If i look at your product:
i can see you use an aim quaternion as reference space.
the difference between this space and your driver helps compture an angle between a common axis : a first twist estimate
lastly you have a batch mutliply divide node which spread twist value along a limb segment( mine support
angle / scale and was trivial and fun to build: ( just be careful as sampling a ramp attribute
is a bit slow with a lot of element ( > 150 ) .

@Personally, I rather use a plug-in which has a good support, someone who cares about his tools,
We can see from your website some really good Tool and UI design. your learning material are also excellent:
Nonetheless, i cant see what you show targeting other people than some animator or beginner rigger?

What make you cone reader better than Michael comet pose reader? Any reason you don’t talk about it
and have written a strip down version?

On your weightDriver you have translation part which combine a joystick element with a ramp:
this part is more interesting but driving a mouth blendshape and using a ramp is quite concerning:
usually for this kind of component ( on face tweaker, UI slider or joystick ),you have to guaranty the straight
correspondence between what you animate and the actual moving of points . hence why for facial animation
those offset are a big no: if your animator need ease in and out he will usually tweak his curve tangent…

Your extract delta file seem to be as well a clone of Chad Vernon cvShapeInverter ( with the same random matrix hack ).
Personally i used real matrix math for that, thats why now im able to invert dual quaternion skin , lattice
deformer ( interesting subject which can help people improves their math skills) and have a look at
skin decomposition. One study can lead to antoehr an will become the foundation to acquire new skills

Texture deformer : something covered extensively by david gould in is complete maya programming book.
displaceD from Hajime Nakamura https://github.com/redpawfx/DisplaceD.
Had a shot at it, quite fun to deal with animatable weights.

your iCollide and sceneAssemblyManager are more informative ( you at least give credit to stretchMesh which help you build your plugin reference)
Any reason again we dont see information on equivalent component?
https://www.youtube.com/watch?v=SEU2nMF6ARs
L3Deformer - Collision Deformer

Jan Lachauer
https://vimeo.com/13150202
https://github.com/Bumpybox/Tapp/blob/master/Maya/plugins/jlCollisionDeformer.py

Maya muscle have still to date unparalleled and unmatched deformer feature ( a pity they are blended
together into one uber node: people have request for years autodesk to split them to no avail
: so guys if you want to access really goo node and deformer just go to maya feedback and vote for this.)

So i guess your opinion reflect your circumstance are coherent as a whole:
your will to help the community is commendable but you seem to operate more as a tool vendor and 3rd party service provider.

Im character TD and i always tried to share my old toys at some point,as open source elements.
but in my eyes having an article explaining a technique is more useful .
I always made my point to give people enough reference link to show people what I study, what was my struggle,
how i overcame a problem or what was my failures.

However after work and my own research i don’t always have time nor energy to provide support to random peoples.
I have nothing to sell and I don’t need to raise my audience nor customer base.
What i do is mostly for my personal enjoyment and tools, custom nodes deformers are a mean to an end not my goal

Releasing a free product is a common business practice (http://creaturerigs.com/stretch-ik-maya-plugin/
https://www.toolchefs.com/?page_id=225 ) it can help you reach new people and companies( nothing wrong with this).

For my part what i want for my peers and my communities is to be self sufficient: make your own experiment,
try commercial product, whatever helps you achieve your goal ( a good animation rig, with good deformations)
but dont lock your self on a 3rd party solution, especially on basic level things.

i think i had something publish since 2014 on github:
quaternion aim constraint[I]
https://github.com/cedricB/circeCharacterWorksTools/blob/master/maya/plug-ins/heimer.py

twist segment node[/I] for angle / scale: support start twist - endTwist and midTweak ( same with scale )
https://github.com/cedricB/circeCharacterWorksTools/blob/master/maya/plug-ins/tortilla.py

twistReader[I] this one one hacking maya orientConstraint node
https://github.com/cedricB/circeCharacterWorksTools/blob/master/maya/plug-ins/twistKnot.py
( have something more self contained never have time to upload)

@agreed that there cannot be a perfect solution:
I as said quite some time ago writing history node which track twist is more tricky to handle
but sampling twist as animator work on the rig can introduce erratic result and be unreliable.
the only time we can guaranty a stable behaviour is when bake the twist ourself and flush anything here before playblast
or point caching.

when you write a divide node you take care of division by zero? So yeah a node operate within a range, and must fail in
predictable manner ( not crashing maya of course ):

Here asking animator to track a twist attribute on a character is to ask to manage 2 shoulders, 2wrists,
2 elbows, 2ankles, 2knees, 2upper legs, 2upper arms and so on: will tire them really quickly and they will
quickly rebell at you.

You are not the first developer to explore this workaround ,a lot of other guys im sure did it long before us.
Had study this some years ago but after some time made my conclusion:
it can work in a lot of simple case but in medium ones the cure will be worse than the disease.

The latest version of maya has a pose and shape editor tool similar to your main product Shape ,did it start to have an impact on your side?
( autodesk have this kind a dirty habbit to integrate their own flavorof poluatr tool: grease pencil/(mark zubrick), steroscopic camera rig, texture hyperveil/asset
container and so on, buying separate product like maya muscle ,nex or mash)