# I need an analytic formula for 3 arms inverse kinematics system

I need an Analytic formula for 3 arms IK system_. I'm currently using Fabrik and CCD solutions but I'm facing low-performance and accuracy issues. So now I'm looking for an Analytic formula.

I'm working on a planar system so a 2D solution would work.

Thanks in advance for any help.

Let's attack this in parts: we'll find where to place the end of the first bone, then figure out where the other two go. Once we've arranged the first bone, what remains is a two-bone IK problem, which we already know how to solve analytically.

The trick is to understand the constraints on where the end of the first bone can end up. It can't be further away from the target than the remaining bones can reach, ie.

Distance(1st bone end, target) <= Length(2nd bone) + Length(3rd bone)


And it also can't be closer to the target than the shortest length the remaining bones can fold to, ie.

Distance(1st bone end, target) >= Abs(Length(2nd bone) - Length(3rd bone)


And lastly, the endpoint of the first bone can't be closer or further from the start point than the bone's own length:

Distance(1st bone end, origin) = Length(1st bone)


Taking these three constraints together, we have an interesection between a circle (the sweep of the first bone) and an annulus (the allowable places the remaining bones can start and still reach the target)

Points where your 1st bone circle (red) intersects the outer rim of the annulus (teal) correspond to solutions where the 2nd and 3rd bone are pulled into a straight line to reach their maximum extent.

Points where it intersects the inner rim correspond to solutions where the remaining two bones are forced to fold 180 degrees to collapse as tightly as possible.

Any intermediate point along the arc(s) of overlap between the circle and annulus (fine solid red curves) are solutions where the second elbow bends some intermediate amount - tighter further in, looser further out.

You can pick any point you like along those curves of overlap - each of the infinite choices corresponds to a feasible solution (barring obstacles / joint angle limits). But some options along these arcs might be better than others, based on considerations like...

• Proximity to the arm's previous pose
• Continuity with the arm's previous motion
• Balancing the amount of bending between the joints
• Prioritizing more bending at freer joints and less at stiffer/more expensive joints

...etc. What heuristics/algorithms you apply here will depend on your context and how you want the arm to behave.

• thank you for the answer, but my issue is there are too many possibilities with your solution, I'm looking for a more accurate way, an Analytic and Trigonometry way to have the same result every time. like the 2 arms solutions. – user3196160 Jan 26 at 23:24
• This is not a trait of this particular solution; it's the nature of the problem itself. When you have this many degrees of freedom, you necessarily have a continuum of potential solutions (outside of edge cases like when the arm is pulled taut). But, you can arbitrarily impose an extra constraint to force the solution down to one point. Say, always picking the point closest to the middle of the annulus's thickness. – DMGregory Jan 26 at 23:30
• One way to see this is to try building an example. Take two pieces of heavy cardboard and fold one leg of a staple through them to join them end-to-end in a hinge. Then put pins through the free ends to fix the start and end points of the arm, bending the elbow hinge at some angle. Push on the elbow: it will resist moving (up to the sturdiness of the material), because it's an isolated solution — no nearby angles work without distorting the bones. Now do the same with 3 bones. When you push on it, it will swing, because most solutions can be smoothly transformed into adjacent valid solutions. – DMGregory Jan 27 at 22:02
• hmm, just found this PDF , it's beyond of my knowledge, but seems there's a true answer ! what do you think? – user3196160 Jan 28 at 2:54
• Once again, your belief that there is a "true" unique answer is false. Throw it away — it will not help you. Even the link you cite says this explicitly: "...uniqueness is not guaranteed. There may not (and in general, will not) be a unique set of joint coordinates for the given end effector coordinates." What this means that you should usually expect to have to choose between a (possibly large, or even continuous) set of solutions. This is unlike the two-bone case which can have only zero, one, or two distinct solutions. Do not expect this to apply to higher orders. – DMGregory Jan 28 at 3:02