computeFullCircleAngle static method

double computeFullCircleAngle({
  1. required Vector2 toDirection,
  2. Vector2? fromDirection,
})

Computes the angle between toDirection and fromDirection, with the result ranging between 0 and 2π radians.

Implementation

static double computeFullCircleAngle({
  required vmath.Vector2 toDirection,
  vmath.Vector2? fromDirection,
}) {
  final a = fromDirection ?? vmath.Vector2(1, 0);
  final b = toDirection;

  final rawAngle = -a.angleToSigned(b);
  if (rawAngle < 0.0) {
    return 2 * math.pi + rawAngle;
  } else {
    return rawAngle;
  }
}