# Inverse Kinematics - hard to implement?

This topic is 5452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I was wondering if anyone has tried to implement IK. I wanted to do it for a school assignment, but I don't know if I have time for it. Does it take a lot of time to implement, and it is really difficult? Thanks.

##### Share on other sites
The inverse kinematics problem is a complicated problem, but it really depends on what kind of solver you try to implement. Do you want to do IK on only two joints, or on any number?

Writing a two bone-solver is pretty easy. It gets more complicated when you want to support more than two bones. Stability is another issue, as well as the integration of joint limit support.

So before you start, first set your exact goals of what you are trying to achieve with it. Some algorithms are harder to implement than others. For example the cyclic coordinate descent (CCD) algorithms is very easy to implement, but getting it to work on a stable way already makes it a lot harder.

A Jacobian Transpose or Jacobian Pseudo Inverse solver are harder to implement, simply becaues there isn't so much info on the web about them. Well, there is a lot of info, but nobody wrote any tutorials about them really in clear plain English. Actually it is pretty easy to implement them. Maybe I should write some tutorials about it sometime :) The hard part of the Jacobian however is adding support for joint limits.

Anyway, again, it depends on what kind of IK algorithm you try to implement. There are plenty of solvers you can implement each with its own complexity.

Cheers,
- John

##### Share on other sites
I see. I was told it could get quite hard so I was asked to consider something else.

So would key-framing be simplier? (I haven't really read about key-framing...what would be the difference between them?)

Thanks.

##### Share on other sites
keyframing is much easier. you just predefine the position/orientation of the geometry for a set of keys and interpolate between them. i.e. an object is at position (0.0f, 0.0f, 0.0f) for key0 and (0.0f, 10.0f, 0.0f) for key10, you can interpolate between them to get a smooth animation.
it gets more complicated if geometry should be morphed using keyframe animations, but it depends on what you need.

##### Share on other sites
As far as I am aware, IK is still an unsolved problem, meaning that all the implementations you'll find are essentially 'hacks' that only work under extremely limited conditions.

##### Share on other sites
Quote:
 Original post by MachikoHi,I was wondering if anyone has tried to implement IK. I wanted to do it for a school assignment, but I don't know if I have time for it. Does it take a lot of time to implement, and it is really difficult?Thanks.

It doesn't take alot of time to implement if you understand the math (assuming you don't implement your own Psuedo inverse solver). I did a constraint based system in my graphics class years ago which is fairly close to IK. It was a 2 week assignment IIRC. Limit it to 2D to keep it simple (its easy enough to expand to 3d when you are done with 2D).

##### Share on other sites
Well, a differant name, but I'll assume the same poster. It isn't so much that IK is "too hard". It is that your instructor seemed to be strongly urging you to modify the existing application. That application has no support for animation at all. So it's like you don't even have cut and paste in a word processor yet so you add in a spell checker. Sure, nice to have at some point, but this ain't the point. Keyframe animation is more generally useful than IK. You have to have much of the same functionality you need for keyframe animation to do IK. Right now the application isn't even useful for playing around to get an understanding of what you are trying to accomplish with IK.

##### Share on other sites
I was under the impression that you normally add ik to a keyframed skeletal model so that a predefined animation would look more natural in different cases such as a character grabing a steering wheel and such.

While on this subject, Im finding it hard to understand how you can play multiple animations at once and how to blend between animations. Someone here pointed me to a article, but it was pretty hard to understand. Ive looked for info on this (and I figured that I would't be hard to find) but I can't really find anything 0_o.

##### Share on other sites
Quote:
 Original post by yodamanI was under the impression that you normally add ik to a keyframed skeletal model so that a predefined animation would look more natural in different cases such as a character grabing a steering wheel and such.While on this subject, Im finding it hard to understand how you can play multiple animations at once and how to blend between animations. Someone here pointed me to a article, but it was pretty hard to understand. Ive looked for info on this (and I figured that I would't be hard to find) but I can't really find anything 0_o.
There are two methods to multiple animations that I've seen before: Blended and local. Blended essentially is what it sounds like - you take two skeletal animations and just average(the weighted kind, not just (a+b)/2) the bone positions (using an angular coordinate system like quaternions, not cartesian coordinates) and dislpay the result. This can be used to play a 'pain' animation while continuing to play other things as well.

For the local kind, you essentially just store different animations seperately, so there might be one animation for the legs (for ex a 'running' animation) and nother for the left arm ('jerk back after shooting') and another for the right arm ('grab a grenade and throw it') so that each part of the body can have its own animation playing at the same time.

##### Share on other sites
Thanks for the advices :) I've decided on keyframing instead to maybe save myself a bit of headaches :) But, I am not too familiar with keyframing+interpolation either so...well, I'll see how it works out.

Quote:
 Original post by LilBudyWizerWell, a differant name, but I'll assume the same poster.

If that was directed to me, I think you are thinking of a different person.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 22
• 17
• 46