1 | initial version |
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.
2 | Suggested edit |
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.