centroid property

Point<double> get centroid

Get a centroid (average point) for Iterable of Points

Implementation

Point<double> get centroid {
  Point<double> p = const Point<double>(0, 0);
  for (final el in this) {
    p += el;
  }
  int n = length;
  if (n == 0) n = 1;
  return Point(p.x / n, p.y / n);
}