calculateCentroid implemented