I am working with geospatial shapes and looking at the centroid algorithm here,
http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon
I have implemented the
For 3d Points, I created a method in C # I hope I can help you:
public static double[] GetCentroid(List listOfPoints)
{
// centroid[0] = X
// centroid[1] = Y
// centroid[2] = Z
double[] centroid = new double[3];
// List iteration
// Link reference:
// https://en.wikipedia.org/wiki/Centroid
foreach (double[] point in listOfPoints)
{
centroid[0] += point[0];
centroid[1] += point[1];
centroid[2] += point[2];
}
centroid[0] /= listOfPoints.Count;
centroid[1] /= listOfPoints.Count;
centroid[2] /= listOfPoints.Count;
return centroid;
}