Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 6 def overlap(box, center, D):
- 7 def check_in(point, hibound):
- 8 return 0 <= point and point <= hibound
- 9 def check_edge(center, D, bound):
- 10 return check_in(center + D, bound) or check_in(center - D, bound)
- 11 # check edges overlap
- 12 overlap = check_edge(center[0], D, box[0]) and check_edge(center[1], D, box[1])
- 13 xleft = max(center[0] - D, 0)
- 14 xright = min(center[0] + D, box[0])
- 15 ybottom = max(center[1] - D, 0)
- 16 ytop = min(center[1] + D, box[1])
- 17 return (overlap, xright-xleft, ytop-ybottom)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement