isClockwise static method

bool isClockwise(
  1. List<GeoCoordinate2D> vertices
)

Check whether the sequence of paths defined by vertices is moving in clockwise or counter-clockwise direction.

Implementation

static bool isClockwise(List<GeoCoordinate2D> vertices) {
  double sum = 0.0;
  for (int i = 0; i < vertices.length; i++) {
    GeoCoordinate2D v1 = vertices[i];
    GeoCoordinate2D v2 = vertices[(i + 1) % vertices.length];
    sum += (v2.x - v1.x) * (v2.y + v1.y);
  }
  return sum > 0.0;
}