centroidStatic static method

Coordinate centroidStatic(
  1. Coordinate a,
  2. Coordinate b,
  3. Coordinate c
)

Computes the centroid (centre of mass) of a triangle. This is also the point at which the triangle's three medians intersect (a triangle median is the segment from a vertex of the triangle to the midpoint of the opposite side). The centroid divides each median in a ratio of 2:1.

The centroid always lies within the triangle.

@param a a vertex of the triangle @param b a vertex of the triangle @param c a vertex of the triangle @return the centroid of the triangle

Implementation

static Coordinate centroidStatic(Coordinate a, Coordinate b, Coordinate c) {
  double x = (a.x + b.x + c.x) / 3;
  double y = (a.y + b.y + c.y) / 3;
  return new Coordinate(x, y);
}