fixed centroid calculation for empty polygons, contours always in clockwise order