calculateCenter function

Point calculateCenter(
  1. List<double> vertices
)

Implementation

Point calculateCenter(List<double> vertices) {
  var cumulativeX = 0.0;
  var cumulativeY = 0.0;
  var index = 0;
  while (index < vertices.length) {
    cumulativeX += vertices[index++];
    cumulativeY += vertices[index++];
  }
  return Point(
    cumulativeX / (vertices.length / 2),
    cumulativeY / (vertices.length / 2),
  );
}