added centroid calculation for complex geometries