getSupportVertex method

Vector2 getSupportVertex(
  1. Vector2 d
)

Get the supporting vertex in the given direction.

Implementation

Vector2 getSupportVertex(final Vector2 d) {
  int bestIndex = 0;
  double bestValue = vertices[0].dot(d);
  for (int i = 1; i < _count; i++) {
    double value = vertices[i].dot(d);
    if (value > bestValue) {
      bestIndex = i;
      bestValue = value;
    }
  }

  return vertices[bestIndex];
}