Added a centroid calculating function for meshes.