apply1 method

void apply1(
  1. Bone bone,
  2. double targetX,
  3. double targetY,
  4. double alpha,
)

Implementation

void apply1(Bone bone, double targetX, double targetY, double alpha) {
  if (!bone.appliedValid) bone.updateAppliedTransform();
  final Bone p = bone.parent!;
  final double id = 1 / (p.a * p.d - p.b * p.c);
  final double x = targetX - p.worldX, y = targetY - p.worldY;
  final double tx = (x * p.d - y * p.b) * id - bone.ax,
      ty = (y * p.a - x * p.c) * id - bone.ay;
  double rotationIK =
      math.atan2(ty, tx) * MathUtils.radDeg - bone.ashearX - bone.arotation;
  if (bone.ascaleX < 0) rotationIK += 180;
  if (rotationIK > 180) {
    rotationIK -= 360;
  } else if (rotationIK < -180) {
    rotationIK += 360;
  }
  bone.updateWorldTransformWith(
      bone.ax,
      bone.ay,
      bone.arotation + rotationIK * alpha,
      bone.ascaleX,
      bone.ascaleY,
      bone.ashearX,
      bone.ashearY);
}