code: public static Point3d centroid(Point3d[] x) {
  		Point3d center = new Point3d();
  		for (Point3d p : x) {
  			center.add(p);
  		}
  		center.scale(1.0 / x.length);
  		return center;
  	}
docs: Calculate the centroid of the point cloud.
  
  @param x
  array of points. Point objects will not be modified
  @return centroid as Point3d