Ask Your Question

Revision history [back]

Each rectangle has only 1 centroid, the coordinates which you are already obtaining. The number of rectangles inside the red rectangle is also the number of centroids. You have 3 elements in for loop, that means 3 centroids.

Each rectangle has only 1 centroid, the coordinates of which you are already obtaining. The number of rectangles inside the red rectangle is also the number of centroids. You have 3 elements in for loop, that means 3 centroids.