Advertisement
Guest User

Untitled

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