My Magical Mathematical Journey Part 1

My mathematical journey into the world of smooth stretch began two weeks ago. Or rather, it started a long time ago when I first learned about smooth stretch from Michael Hutchinson’s cool Elastik plugin. At that time I tried to replicate it using just sweat, blood, an XSI Blog post on the matter for some math insight and native Maya nodes.

Smooth stretch is actually on my latest (and now outdated) demo reel. That version was my second attempt at smooth stretch. Version 2.0. This was my third attempt. Version 3.0. There’s something magical about the third attempt of any problem. By then you know the real issues. You know what to concentrate on and the pitfalls to avoid. You have the time to concentrate on what’s really important. In short, the third attempt is where shit gets done. But what is smooth stretch, and what does it solve? Smooth stretch is a way to solve the popping that occurs on an IK chain when it reaches its maximum length (aka, an IK pop). Smooth stretch solves this by changing the length of the IK chain as it nears full extension.

In a stretchy IK system, smooth stretch eases the transition from rotational movement to linear movement. In a stretchy IK system a set of joints will rotate until they reach their maximum extension. Then they will then instantly begin to scale towards the IK handle (linear translation). Smooth stretch eases the transition between these two types of movement by starting to scale the joints (move them linearly) while they are still rotating.

The concept is relatively simple. The real question is, how do you know when to start easing this transition and by how much? In my first and second iterations of smooth stretch I focused on interpolating between two functions over a given time. The two functions were simply the rotation movement and linear movement of the joints. The interpolation was an animation curve I made in Maya. This had two major problems with it. The first problem was mostly an aesthetical one. The animation curve I drew in Maya was not something I could represent easily with math. It was messy. It was also not mathematically derived. I could judge how much I liked the curve by eyeballing the results, but with rigging I’ve grown to distrust doing things like that when dealing with math. The second problem was a mathematical one. If I represented the interpolation these two functions by using a Maya animation curve and that curve is embedded in an equation, how do I solve this for an IK/FK switch?

Things got messy from there. This was not a good solution in my opinion. While it could have been possible to solve my IK/FK switch by representing the hermite curve that the Maya animation curve represented, solving it as a non-parametric function and use that to solve my original equation… It was far beyond anything I could do at the time (and still probably is). Obviously, if you’ve seen my demo reel, you know I must have done something because I show an IK/FK switch with smooth stretch in there. I “solved” it by treating the entire equation as a black box. I iteratively solved the equation by guessing at the answer using a modified binary search. It would plug a guess into Maya, see if the result was close to what it should be, increase or decrease the value depending on what it got back, and eventually find the answer to the specified accuracy.

The solution was definitely a hack in my mind. And not the good kind of hack. The kind of hack you make when desperation sets in and nothing else works. Or deadlines start looming.

This post is looking like it will be epic in length, so I’m going to split it up into a few posts. See you next time as we delve further into my smooth stretch journey.