My situation
Input: a set of rectangles
each rect is comprised of 4 doubles like this: (x0,y0,w,h)
they are not "rotated" at any angle, all they are "normal" rectangles that go "up/down" and "left/right" with respect to the screen
they are randomly placed - they may be touching at the edges, overlapping , or not have any contact
I will have several hundred rectangles
this is implemented in C
I need to find
union of area A and B if overlapped
Example
The image below contains two rectangles: A,B
A and B overlap
What I am looking for is the total area of two region
<br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br />
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <br />
AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB<br />
AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB <br />
AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB <br />
AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB <br />
AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBB<br />
<br />