Skip to main content
Reintroducing guarantee with inner limit, making second circle an annulus
Source Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373

Draw a circle around your origin point, whose radius isLet's attack this in parts: we'll find where to place the lengthend of yourthe 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.

Draw a second circle around your target point, whose radiusThe trick is to understand the sum ofconstraints on where the lengthsend of your latter twothe 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)

IfAnd it also can't be closer to the circles do not overlap (ie. D(origin, target) > L(B1) + L(B2) + L(B3) ), or than the second circle is wholly insideshortest length the first (ie. D(origin, target) + L(B2) + L(B3) < L(B1) )remaining bones can fold to, then there is no feasible solutionie.

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

If they do intersectAnd lastly, or the endpoint of the first circle is wholly insidebone can't be closer or further from the second, then choose anystart point onthan the firstbone's own length:

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

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

Diagram of three potential solutions

Points where your second1st bone circle. This will be (red) intersects the endouter rim of your firstthe annulus (teal) correspond to solutions where the 2nd and 3rd bone are pulled into a straight line to reach their maximum extent.

What remains is now aPoints where it intersects the inner rim correspond to solutions where the remaining two-bone IK problem bones are forced to get from this first bone endpointfold 180 degrees to collapse as tightly as possible.

Any intermediate point along the target, and you're guaranteed thatarc(s) of overlap between the target is in rangecircle and annulus (though differences in arm lengths, joint angle constraints, or obstacles could still block the solutionfine solid red curves). You can apply are solutions where the normal twosecond elbow bends some intermediate amount -bone techniques to that reduced problem tighter further in, looser further out.

The trick here is whenYou can pick any point you have a wide rangelike along those curves of possible points for that first boneoverlap - each of the infinite choices corresponds to end ata feasible solution (barring obstacles / joint angle limits). SomeBut some options along these arcs might be better than others, based on considerations like...

  • Differences in length between your remaining bones
  • 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.

Draw a circle around your origin point, whose radius is the length of your first bone.

Draw a second circle around your target point, whose radius is the sum of the lengths of your latter two bones.

If the circles do not overlap (ie. D(origin, target) > L(B1) + L(B2) + L(B3) ), or the second circle is wholly inside the first (ie. D(origin, target) + L(B2) + L(B3) < L(B1) ), then there is no feasible solution.

If they do intersect, or the first circle is wholly inside the second, then choose any point on the first circle that's inside your second circle. This will be the end of your first bone.

What remains is now a two-bone IK problem to get from this first bone endpoint to the target, and you're guaranteed that the target is in range (though differences in arm lengths, joint angle constraints, or obstacles could still block the solution). You can apply the normal two-bone techniques to that reduced problem.

The trick here is when you have a wide range of possible points for that first bone to end at. Some options might be better than others based on considerations like...

  • Differences in length between your remaining bones
  • 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.

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)

Diagram of three potential solutions

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.

correction to guarantee — this can still fail with uneven bone lengths
Source Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373

Draw a circle around your origin point, whose radius is the length of your first bone.

Draw a second circle around your target point, whose radius is the sum of the lengths of your latter two bones.

If the circles do not overlap (ie. D(origin, target) > L(B1) + L(B2) + L(B3) ), or the second circle is wholly inside the first (ie. D(origin, target) + L(B2) + L(B3) < L(B1) ), then there is no feasible solution.

If they do intersect, or the first circle is wholly inside the second, then choose any point on the first circle that's inside your second circle. This will be the end of your first bone.

What remains is now a two-bone IK problem to get from this first bone endpoint to the target, and you're guaranteed at least one feasible solutionthat the target is in range (barringthough differences in arm lengths, joint angle constraints, or obstacles could still block the solution). You can apply the normal two-bone techniques to that reduced problem.

The trick here is when you have a wide range of possible points for that first bone to end at. All lead to feasible solutions, but someSome options might be better than others based on considerations like...

  • Differences in length between your remaining bones
  • 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.

Draw a circle around your origin point, whose radius is the length of your first bone.

Draw a second circle around your target point, whose radius is the sum of the lengths of your latter two bones.

If the circles do not overlap (ie. D(origin, target) > L(B1) + L(B2) + L(B3) ), or the second circle is wholly inside the first (ie. D(origin, target) + L(B2) + L(B3) < L(B1) ), then there is no feasible solution.

If they do intersect, or the first circle is wholly inside the second, then choose any point on the first circle that's inside your second circle. This will be the end of your first bone.

What remains is now a two-bone IK problem to get from this first bone endpoint to the target, and you're guaranteed at least one feasible solution (barring joint angle constraints or obstacles). You can apply the normal two-bone techniques to that reduced problem.

The trick here is when you have a wide range of possible points for that first bone to end at. All lead to feasible solutions, but some 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.

Draw a circle around your origin point, whose radius is the length of your first bone.

Draw a second circle around your target point, whose radius is the sum of the lengths of your latter two bones.

If the circles do not overlap (ie. D(origin, target) > L(B1) + L(B2) + L(B3) ), or the second circle is wholly inside the first (ie. D(origin, target) + L(B2) + L(B3) < L(B1) ), then there is no feasible solution.

If they do intersect, or the first circle is wholly inside the second, then choose any point on the first circle that's inside your second circle. This will be the end of your first bone.

What remains is now a two-bone IK problem to get from this first bone endpoint to the target, and you're guaranteed that the target is in range (though differences in arm lengths, joint angle constraints, or obstacles could still block the solution). You can apply the normal two-bone techniques to that reduced problem.

The trick here is when you have a wide range of possible points for that first bone to end at. Some options might be better than others based on considerations like...

  • Differences in length between your remaining bones
  • 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.

Source Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373

Draw a circle around your origin point, whose radius is the length of your first bone.

Draw a second circle around your target point, whose radius is the sum of the lengths of your latter two bones.

If the circles do not overlap (ie. D(origin, target) > L(B1) + L(B2) + L(B3) ), or the second circle is wholly inside the first (ie. D(origin, target) + L(B2) + L(B3) < L(B1) ), then there is no feasible solution.

If they do intersect, or the first circle is wholly inside the second, then choose any point on the first circle that's inside your second circle. This will be the end of your first bone.

What remains is now a two-bone IK problem to get from this first bone endpoint to the target, and you're guaranteed at least one feasible solution (barring joint angle constraints or obstacles). You can apply the normal two-bone techniques to that reduced problem.

The trick here is when you have a wide range of possible points for that first bone to end at. All lead to feasible solutions, but some 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.