Simple IK solver – with source!

Usage: Click and drag the points around to reset the position of the two points. If you want to use the solver, download it here!

[kml_flashembed publishmethod=”static” fversion=”11.0.0″ movie=”http://www.zachernuk.com/wp-content/2013/03/IKToy.swf” width=”600″ height=”600″ targetclass=”flashmovie”]

Get Adobe Flash player

[/kml_flashembed]

 

It has been a busy time at Resn! We have been hard at work on some pretty cool games/toys that should be available for the up-and-coming LEAP Motion device. It’s even in the paper! The device is amazing, and I’ve got another post or two in the works just to describe what it’s like and how it’s going to change everything. In the meantime, we’ve had to make some games for it. The game  I’ve been working on has puppets that need semi-realistic movements, and so I’ve been using a mixture of Box2DAS3 for the general physics solver, and an Inverse Kinematics (IK) solver that I worked out myself. I’ve never played with IK before, so it was nice to have an opportunity. I built it because I couldn’t find a solver that was simple enough for my needs, and so here it is!

That solver’s not finished! Or, obeying our lord YAGNI

If you’re a stickler for details, you might notice that the solver’s not actually complete. It only deals with two limbs that are exactly the same length. Why bother releasing that? First, because it’s all I needed – The arms and legs of our puppets were close enough to symmetrical in length that it wasn’t necessary to add all of the extra detail. Second, it was kind of an exercise in minimalism. For those unfamiliar with the term, YAGNI stands for ‘You Ain’t Gonna Need It.’ Programmers are notorious for trying to cover every possible situation before beginning anything – which is great for being prepared for everything… eventually. If you want to get anything done, though, it’s necessary to work on only those features that are strictly, immediately necessary.  It’s harder than it sounds to stick to that, though.

So here’s my IK solver, such as it is. If you want the solver on its own you can grab it here, and if you’d prefer the sample project you can grab that here. I hope it’s useful!