Overlapping rectangles -- HELP

Overlapping rectangles -- HELP

Post by Gary Kushn » Sat, 31 Oct 1992 10:07:12



I thought this would be trivial problem, but...

If I have the 4 vertices of two rectangles, is there a quick and easy way
to tell if they overlap.  I don't even need the overlapping region!

All I've thoght of so far is brute force checing several cases.  
eg.  one in other, other in one, one with vertices in other, other with
verticies in one, one with line through other, other with line through
one...  I must be missing the boat big time here!

Any help would be GREATLY appreciated!

Thanks,
-Gary

 
 
 

1. Checking rectangle overlap in a plane

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.

2. wobbling a aircraft?

3. Overlap of Rectangles

4. "Red's Nightmare" availability

5. Checking rectangle overlap in a plane

6. Looking for volume data for segmentation research

7. Moving rectangles to avoid overlapping

8. Rendering Farm

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