I am looking for a way to calculate the common areas covered by multiple overlapping polygons. The polygons are all right-angled, if that helps makes things easier.
So for example:
BBBBB BBBBB AAA---BB AAA---BB AAAAAA AA--AA AA--AA LL LL LLLLLL LLLLLL
I would like to find the common area covered by A, B and L, which would equal: B = 5x4 = 20 + A = 6x5 = 30 + L = 4x2 + 6x2 = 20 = 70 minus overlapping areas: - 10 = 60 (common area covered by all polygons)
I need to be able to cater for situations where 3 or more polygons occupy the same area. Is there a suitable algorithm for this, which could take arrays of arrays of x/y co-ordinates as inputs? (sample Java source code would be very welcome).
A classical way of computing such an area is to use a sweep algorithm. You can have a look at question Area of overlapping rectangles to get a description of the algorithm in the simpler case of rectangles.
Then you can either decompose your polygons into rectangles, or adapt the sweep algorithm so that this decomposition is done implicitly during the sweep.