## Overlapping rectangles -- HELP

### Overlapping rectangles -- HELP

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

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.