Q: Outline of overlapping rectangles

Q: Outline of overlapping rectangles

Post by Rob Hoffma » Wed, 11 Aug 1993 20:53:49



Hi everybody, it's good thing to have this newsgroup around (I won't ask
for the FAQ)l! I hope some graphics wizzard can help me out on this
one (me being new to the field).

I'm looking for an algorithm that can do the following:

Given two or more overlapping rectangles, given the four corner-coordinates
(x,y) of every rectangle. What are the coordinates of the
polygon that is made up from these rectangles?

I realize that this is special case of overlapping polygons, but I only
need it for rectangles. To make things (more) clear, a simple example
with two overlapping rectangles A and B. Asterisks (*) show the coordinates
of the resulting polygon. It should be noted that the rectangles need not
be overlapping with 90degree angles. It just was easier to draw them
that way here.

                *-------*
                |   A   |
                |       |
        *-------*-------*----------*
        |       |       |          |
        | B     | A^B   |     B    |
        *-------*-------*----------*
                |       |
                |       |
                |   A   |
                *-------*

And the resulting polygon:

                *-------*
                |       |
                |       |
        *-------*       *----------*
        |                          |
        |                          |
        *-------*       *----------*
                |       |
                |       |
                |       |
                *-------*

Maybe somebody got an algorithm (or even C implementation?) at hand or
has a clue in where to find it. Thanks for any response by E-mail
or in the newsgroup!

Greetings from Holland, Rob.