class_docstr: A basic Rect class. Assumes tl <= br.
class_docstr_tok: ["A","basic","Rect","class",".","Assumes","tl","<","=","br","."]
docstr: Does the circle intersect with this rect?
docstr_tok: ["Does","the","circle","intersect","with","this","rect","?"]
code: def intersects_circle(self, pt, radius):
      """Does the circle intersect with this rect?"""
      # How this works: http://stackoverflow.com/a/402010
      rect_corner = self.size / 2  # relative to the rect center
      circle_center = (
          pt - self.center
      ).abs()  # relative to the rect center
  
      # Is the circle far from the rect?
      if (
          circle_center.x > rect_corner.x + radius
          or circle_center.y > rect_corner.y + radius
      ):
          return False
  
      # Is the circle center inside the rect or near one of the edges?
      if (
          circle_center.x <= rect_corner.x
          or circle_center.y <= rect_corner.y
      ):
          return True
  
      # Does the circle contain the corner of the rect?
      return circle_center.dist_sq(rect_corner) <= radius**2
  
imports: import collections
  import math
  import random
label_desc: Use image node_id 22 for calling the Rect obj's underlying member method code with example usage: obj.intersects_circle(pt, radius) and returns: unknown, False, True