def is_close_to(self, other: 'Position', threshold: float): x_diff = self.point.x * threshold if self.point.x else threshold y_diff = self.point.y * threshold if self.point.y else threshold x_point = self.point.x + x_diff y_point = self.point.y + y_diff new_pos = Position(x_point, y_point) radius = self.calculate_distance_from(new_pos) area = Circle(self.point, radius) return area.encloses_point(other.point)
def enclosing_circle(P: [Point]): C_min = Circle(Point(250, 250), 10000) # Two points for a in P: for b in P: if b == a: continue C = get_circle(a, b) for d in P: if d == b or d == a: continue if not C.encloses_point(d): break else: if C.radius < C_min.radius: C_min = C # Three points for a in P: for b in P: if b == a: continue for c in P: if c == a or c == b: continue C = Circle(a, b, c) for d in P: if d == a or d == b or d == c: continue if not C.encloses_point(d): break else: if C.radius < C_min.radius: C_min = C return C_min