I am trying to determine the space for each of the rectangles (red, blue, orange, etc) where there is no other rectangles intersecting. The points of each rectangle is known. The number of rectangles and the number of rectangles that are intersecting will change depending on the dataset being run so are not limited to 5.
eg:
With this mock up Intersecting Rectangles Start Point.
I would expect the blue rectangle to return that the total area was being intersected. While the Pink Rectangle would show that a portion is still ok. eg. Area that are not intersected
| Rectangle | Total Area | Area Of Intersection |
|---|---|---|
| Red | 1000cm2 | 300cm2 |
| Orange | 900cm2 | 400cm2 |
| Blue | 700cm2 | 700cm2 |
| Pink | 200cm2 | 180cm2 |
| Green | 900cm2 | 420cm2 |
I was using the inclusion exclusion principle in earlier runs when it was just 2 intersecting rectangles but due to their being an unknown number of intersecting rectangles I don't think it is feasible especially when the intersecting rectangles could also be overlapping like the pink rectangle.
I am also not stuck to doing this within SQL but I'm not familiar with any other languages at this point.