projectVertices static method

({double max, double min}) projectVertices(
  1. List<Vector2> vertices,
  2. Vector2 axis
)

Implementation

static ({double min, double max}) projectVertices(
  List<Vector2> vertices,
  Vector2 axis,
) {
  double min = double.maxFinite;
  double max = -double.maxFinite;
  for (var v in vertices) {
    double proj = v.dot(axis);

    if (proj < min) {
      min = proj;
    }
    if (proj > max) {
      max = proj;
    }
  }
  return (min: min, max: max);
}