Alternatively titled "I'd like to get off Mr. Bones Wild Ride"...
So, yeah... I'm still here.
Long story short, I've been busy working on my character rig and dealing with all the lovely little issues that have crept up along the way. One of those issues has to do with the subject of "twist extraction", which is essentially the black art of aligning a rotation along a specific axis to the orientation of another joint further down the chain.
As I quickly found out, this is pretty much a requirement for creating high quality rotations around the shoulders, wrists, and legs. There's only one problem- it's nearly impossible to do this using any of the standard rotation systems (HPB, XYZ, etc). They all have issues with singularities and gimbal lock near 90°, which makes them unsuitable for determining something as simple as the twist of a wrist (which is actually a fairly complicated thing as far as computers are concerned).
Enter quaternions.
Quaternions are an alternative system for representing rotations in 3D space, and have some attractive properties that can make them more useful for dealing with problems like this (above and beyond allowing you to easily add/subtract angles, converting angles between different rotation orders, and blending between angles by following the shortest path along the surface of a unit sphere). They also happen to be one of the more stable methods of extracting twist rotations in other 3D programs, but unfortunately the one I'm stuck with has absolutely zero support for quaternions of any kind.
Soooo...
Rather than giving up (as I'm positive any sane individual would have done at this point), I decided to try and implement my own version of quaternions as a custom data type within CINEMA 4D, then extend that support all the way into Xpresso (our node graph editor) so that I could leverage the new data type to solve these issues for me. The above screenshot is part of that code. Approximately 6500 lines of C++ were written over the span of 2 weeks, imbuing C4D with the ability to handle and manipulate quaternions throughout the entire user interface as if they were part of the base program itself.
Dan
2019-02-13 06:05:28 +0000 UTC