【面】判断两个矩形是否相交

1
2
3
4
5
6
7
8
9
10
11
12
13
14
def isOverlap(rec1, rec2):
x1 = max(rec1[0], rec2[0])
y1 = max(rec1[1], rec2[1])

x2 = min(rec1[2], rec2[2])
y2 = min(rec1[3], rec2[3])

if x1 < x2 and y1 < y2:
return True
else:
return False

print(isOverlap([0,0,2,2], [1,1,3,3]))
print(isOverlap([0,0,1,1], [1,0,2,1]))
0%