什么是测试2个矩形是否相交的快速方法?快速矩形到矩形相交
在互联网上搜索想出了这个一行代码(WOOT!),但我不知道如何把它写在Javascript中,它似乎是在一个古老的形式C的++编写。
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 < r1->left
|| r2->top > r1->bottom
|| r2->bottom < r1->top
);
}
我想你已经在你的副本有一个错字/粘贴 – fmark 2010-05-02 03:35:26
好了,这是从哪儿它,它看起来同我 - http://tekpool.wordpress.com/2006/ 10/11/rectangle-intersection-determining-if-two-given-rectangles-intersect-each-other-or-not/ – 2010-05-02 03:36:50
原文有一个错字。 'r2->左'没有意义。由于HTML转义问题,它可能会被破坏。 – 2010-05-02 03:41:53