Emulate IK behaviour with AimConstraints


#1

I’m wondering if it’s possible to emulate a simple IK behaviour consisting of three joints (two joints actually moving, like an arm or a leg) only with constraints?

I’ve tried to figure out how IK solvers work, but when googling for it I mostly find extremely long documents talking about IK with several joints, while I’m looking for the simplest form of IK possible. So if anyone knows of a video that explains how IK works under the hood with visualizations, that would be awesome :slight_smile:

EDIT: Oh I forgot one important thing, the end effector will only need to move in two axises (Y/X - up/down & forward/backward). So it would actually be a 2D IK.


#2

Cult of Rig goes through making a basic IK solver using Maya nodes


#3

Yes, I’ve played around with fake 3-joint IK chains with various constraint setups. I think I’ve used a few in production, too, for various reasons, like a really nice hind leg for dogs that was super easy to animate from sitting to standing, to rearing up on the hind legs. That was sort of a mix of IK and aim constraints and such. I also faked IK arms and legs in 2D in Flash back around 2002 using simple trig. It was for a 2D girl dancer who was intended to dance along with music, using a Winamp plugin that could play Flash movies, and send IIRC high, mid, and low frequency values to the flash movie as variables. I did manage to make a bouncing car, which added thrust to the wheels for bouncing based on the intensity of the bass line, and I got the girl to a point of being fully posable (like a jointed paper doll), but I didn’t finish the full, dancing version of her for use with the plugin. It was just a toy project, right before I got my first industry job.

ISTR that many-joint IK chains are a difficult problem, mathematically speaking, and so, yes, they inspire large research papers into better/faster solutions/approximations, which may be what you’ve found.


#4

A two-bone IK system is absolutely constructable from default Maya nodes, and in the majority of circumstances, I prefer doing just that (Maya’s IK handles are kind of bad).

You have two lines. Draw another line - you have a triangle. This is now a school-level geometry problem. You in particular only need it in 2D, and that makes it even easier. Get the vector between the start and the endpoint, and divide by 2 to get the midpoint (recommend plusMinusAverage and MultiplyDivide). Now the angle of your joint (theta) is given through basic trig from the distance to midpoint (L) and length of your joint (H), as inverseCos(L/H).

The above only works for systems where joint lengths are equal - the condition you want to satisfy is that the two joints for hypotenuses of two right triangles - it may be that the boundary between them lies somewhere other than the midpoint on the vector.

In short, make triangles.