Can this rectangle to rectangle intersection code still work?
- by Jeremy Rudd
I was looking for a fast performing code to test if 2 rectangles are intersecting.
A search on the internet came up with this one-liner (WOOT!), but I don't understand how to write it in Javascript, it seems to be written in an ancient form of C++.
Can this thing still work? Can you make it work?
struct
{
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;
bool IntersectRect(const RECT * r1, const RECT * r2)
{
return ! ( r2->left > r1->right
|| r2->right left
|| r2->top > r1->bottom
|| r2->bottom top
);
}