矩形结构:
R(left, top, right, bottom)
(left, top)为矩形左上角;
(right, bottom)为矩形右下角;
矩形重叠:A+B=C
矩形C是矩形A和矩形B重叠的部分
所以:
C(left) = max(A(left), B(left))
C(right) = min(A(right), B(right))
C(top) = max(A(top), B(top))
C(bottom) = min(A(bottom), B(bottom))
矩形相交判断:
If (C(left) > C(right) || C(top) > C(bottom))
{
矩形没有相交
}