Calculating centroid, and creating a convex hull