added method to compute and query the centroid of an object