code: public Coordinate getCentroid() {
  		if (isEmpty()) {
  			return null;
  		}
  		double sumX = 0;
  		double sumY = 0;
  		double totalLength = 0;
  		for (int i = 0; i < coordinates.length - 1; i++) {
  			double length = coordinates[i].distance(coordinates[i + 1]);
  			totalLength += length;
  			double midx = (coordinates[i].getX() + coordinates[i + 1].getX()) / 2;
  			sumX += length * midx;
  			double midy = (coordinates[i].getY() + coordinates[i + 1].getY()) / 2;
  			sumY += length * midy;
  		}
  		return new Coordinate(sumX / totalLength, sumY / totalLength);
  	}
docs: The centroid is also known as the "center of gravity" or the "center of mass".
  
  @return Return the center point.