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,
) {
  var min = double.maxFinite;
  var max = -double.maxFinite;
  for (final v in vertices) {
    final proj = v.dot(axis);

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