def __verify_intersections(self, next_point: Point, best_wall: Wall, walls: list): for wall in walls: intersection = get_intersection(Point.zero(), best_wall.direction.normalized, wall.begin_point, wall.direction) angles_diff = get_angles_diff(get_angle(intersection), get_angle(next_point)) if self.__is_safe_spot( next_point, intersection ) and angles_diff < 45 and wall.intersect(next_point): return self.__find_next_point( wall, [w for w in walls if w != best_wall]) return next_point
def closer_point_from_origin(self) -> Point: closer_point_on_line = get_intersection( Point.zero(), rotate_vector(self.direction, 90), self.begin_point, self.direction) closer_point_diff = closer_point_on_line - self.begin_point angles_diff = round( abs( abs(get_angle(self.direction)) - abs(get_angle(closer_point_diff.normalized))), 4) if closer_point_diff.dist < 0 or closer_point_diff.dist > self.dist or angles_diff != 0: if self.begin_point.dist < self.end_point.dist: return self.begin_point else: return self.end_point return closer_point_on_line
def __reset_location_and_rotation(self): self._location = Point.zero() self._rotation = 0.0