Vixen
02b45cc4
csharp
public static class TwoBoneIk

Bends a two-bone chain so its end reaches a point: the arm and the leg solver, solved exactly rather than iterated.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Analytic, and there is no reason for it not to be. Two bones and a target is a triangle with three known side lengths, so the interior angles come out of the law of cosines in closed form — no iteration, no convergence threshold, no frame-rate-dependent settling. CCD and FABRIK exist for chains longer than this, where there is no closed form; using them on an elbow is paying for generality nothing needs and getting a solution that is slightly different every frame.

Only rotations change. The local translations — the bone lengths — are left exactly as the pose had them, which is what stops IK from stretching a character. A target beyond the chain's reach gets a straightened limb pointing at it rather than a longer limb, and that is the correct failure: the character visibly cannot reach, which is information, where a stretched arm is a bug that looks like a bug.

The construction follows the standard analytic form (Ryan Juckett's, also in Unity's and Unreal's two-bone constraints): correct the two interior angles to what the target's distance demands, then swing the whole chain to point at the target.

Methods (1)

Used by (4)

  • DefaultChainSolverVixen.Animation
  • FootPlacementVixen.Animation
  • IkTestsVixen.Animation.Tests
  • ReachVixen.Animation.Tests