Checking rectangle overlap in a plane

Checking rectangle overlap in a plane

Post by Peter Dav » Wed, 28 Nov 1990 23:46:35




>    can anyone tell me a quick algorithm to check for overlap of
>two rectangles that lie in the same plane and have the same orientation?
>(Note: must allow for the possibility that one is totally included in
>the other.)

If the sides are parallel to the axes, it's easy:  If the high X of one is less
then the low X of the other, or the high Y of one is less than the low Y of the
other, they DON'T overlap.  Otherwise, they do.  This can be determined in 4
comparisons:

        if ((hi_x1 < lo_x2) || (hi_x2 < lo_x1) ||
            (hi_y1 < lo_y2) || (hi_y2 < lo_y1))
          {
            They don't overlap
          }
        else
          {
            They do
          }

If the sides are not parallel to the principal axes, but they have the same
orientation (ie, the sides are parallel to each other), then it might be easiest
to just transform the coordinates so they are parallel to the X and Y axes.

 
 
 

1. Checking rectangle overlap in a plane

Hi,

    can anyone tell me a quick algorithm to check for overlap of
two rectangles that lie in the same plane and have the same orientation?
(Note: must allow for the possibility that one is totally included in
the other.)

Thanks

-Afzal Ballim

2. duotone export for import into PageMaker

3. Overlapping rectangles -- HELP

4. Generating Land Textures...

5. Overlap of Rectangles

6. make error

7. Moving rectangles to avoid overlapping

8. how to change binary file to GIF file?

9. Merging unit sqaures into non-overlapping rectangles

10. area of rectangles overlap algorithm needed

11. Polygon from overlapping Rectangles?

12. Rectangles overlapping

13. Overlapping rectangles