projectCircle static method

({double max, double min}) projectCircle(
  1. Vector2 center,
  2. double radius,
  3. Vector2 axis
)

Implementation

static ({double min, double max}) projectCircle(
  Vector2 center,
  double radius,
  Vector2 axis,
) {
  final direction = axis.normalized();
  final directionAndRadius = direction * radius;

  final p1 = center + directionAndRadius;
  final p2 = center - directionAndRadius;

  var min = p1.dot(axis);
  var max = p2.dot(axis);

  if (min > max) {
    // swap the min and max values.
    final t = min;
    min = max;
    max = t;
  }
  return (min: min, max: max);
}