findClosesPointOnPolygon static method
Implementation
static int findClosesPointOnPolygon(
Vector2 circleCenter,
List<Vector2> vertices,
) {
int result = -1;
double minDistance = double.maxFinite;
for (int i = 0; i < vertices.length; i++) {
Vector2 v = vertices[i];
double distance = v.distanceTo(circleCenter);
if (distance < minDistance) {
minDistance = distance;
result = i;
}
}
return result;
}