An Inverse Kinematics Algorithm in a single GIF.





For decades since its inception Inverse Kinematics had remained notoriously tricky to implement. Methods to solve IK chains ran the gamut from analytic (triangle rule – only works in some cases), to iterative (CCD – kind of shitty results), and most successfully (but most daunting) Jacobian inverses and Taylor series expansions.

I asked a mathematician with some experience implementing IK (using the last two techniques), and he recommended that I avoid IK altogether.

So I’m thinking there’s gotta be a better way. And at some point I realized that Inverse Kinematics is, as a problem, a strict subset of cloth simulation. And I happened to have already written a cloth simulator. Which meant I could just recycle that code and get myself a really nice IK system.

But surely, I couldn’t be the first person to have realized this, so I looked it up, and indeed, I am not. It turns out that just a few years ago, an IK method called FABRIK (Forward and Backward Reaching Inverse Kinematics) was proposed. FABRIK, was its self based on a modification of a rope physics algorithm.

FABRIK gives really REALLY excellent results. And it’s fast. And it’s versatile (naturally extends to support multiple effectors, joint limits [edit: with significant compensation required for edge-cases, but I think I’ll write a post on this soon], the works). And it can be explained in a single .gif.

From the time computer simulated IK was first posited, it took humans as a species 20 years to come up with this solution.

