I have a problem in which I need to calculate the coordinates of all corners in a given polygon. The information I have available is a list of tiles/squares within that shape. The shape is always made out of these squares and always aligns exactly on the grid. Two examples of these kinds of shapes are as follows:
Taking the first example shape, I would like to know the coordinates of the corners represented by the dots in the following image:
The exact information I have available is a list of all the squared tiles that are in that shape. They are represented by their most bottom-left corner. So in example 1, I have the following information:
$$(0,0); (0,1); (0,2); (0,3); (1,0); (1,1); (1,2); (1,3); (2,0); (2,1); (2,2); (3,0); (3,1); (3,2); (4,2); (5,2); (5,3)$$
I tried to iterate the list and remove the inside squares so that I only have the outer ones left. Then I would take all the maximum and minimum values. The problem then, is that I only get the four most outer corners and not the corners in the middle of the shape.
Anyone know a good way to approach this?
Best Answer
Try it online