Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def intersects_bboxs(x1, y1, x2, y2, x11, y11, x22, y22):
- """
- check if bboxs is intersects
- :param x1: 1st bbox
- :param y1: 1st bbox
- :param x2: 1st bbox
- :param y2: 1st bbox
- :param x11: 2d bbox
- :param y11: 2d bbox
- :param x22: 2d bbox
- :param y22: 2d bbox
- :return: True (if intersect); False (if not)
- """
- x2 = x1 + x2
- y2 = y1 + y2
- x22 = x11 + x22
- y22 = y11 + y22
- s1 = (x1 >= x11 and x1 <= x22) or (x2 >= x11 and x2 <= x22)
- s2 = (y1 >= y11 and y1 <= y22) or (y2 >= y11 and y2 <= y22)
- s3 = (x11 >= x1 and x11 <= x2) or (x22 >= x1 and x22 <= x2)
- s4 = (y11 >= y1 and y11 <= y2) or (y22 >= y1 and y22 <= y2)
- return (True if ((s1 and s2) or (s3 and s4)) or ((s1 and s4) or (s3 and s2)) else False)
Advertisement
Add Comment
Please, Sign In to add comment