I am looking for a pseudo code logic that would find n
equally sized areas in a given polygon. No space should be between or outside the matched areas. First valid match of areas should be returned.
Assuming following polygon [2,2, 3,1, 5,1, 5,4, 4,5, 2,3]
as an input:
...and 3
as a parameter a valid output could be [ [2,2, 3,2, 3,3, 4,3, 4,5, 2,3], [2,2, 3,1, 5,1, 4,2, 4,3, 3,3, 3,2], [4,5, 4,2, 5,1, 5,4] ]
:
Another valid output with parameter 3
is [ [3,4, 3,3, 4,3, 4,2, 3,2, 3,1, 2,2, 2,3], [4,3, 4,2, 3,2, 3,1, 5,1, 5,3], [3,4, 3,3, 5,3, 5,4, 4,5] ]
:
Please note that areas don't have to share same center point. One or more areas may happen to fall right between other areas inside the polygon.
Here is another example of sample input/output.
Assuming following polygon [1,3, 1,1, 7,1, 7,2, 8,2, 8,3, 5,6, 4,6]
as an input:
..and 5
as a parameter a valid output could be [ [1,3, 1,1, 3,1, 3,2, 4,3, 3,4, 3,3], [3,2, 3,1, 7,1, 7,2, 6,2, 6,3, 5,3, 5,2], [6,2, 8,2, 8,3, 6,5, 5,5, 5,4, 6,4], [1,3, 3,3, 3,4, 5,5, 6,4, 6,5, 7,5, 6,6, 5,6], [3,4, 4,3, 3,2, 5,2, 5,3, 6,3, 6,4, 5,4, 4,5] ]
:
Following assumptions are made:
direction of all borders is divisible by 45
integer coordinates are used for all polygons
integer area of input polygon is always divisible by
n
all polygons may be either convex or concave ones
solvable, meaning
n
areas can fit properly into the given polygon