MCPcopy Create free account
hub / github.com/PJLab-ADG/OASim / in_collision

Method in_collision

limsim/utils/obstacles.py:51–76  ·  view source on GitHub ↗

check if two rectangles intersects (in collision) Args: other_rectangle (Rectangle): another rectangle Returns: bool: True if two rectangle intersects, False otherwise

(self, self_center: np.ndarray,
                     other_rectangle: 'Rectangle',
                     other_center: np.ndarray)

Source from the content-addressed store, hash-verified

49 return center + np.array([rotation.dot(point) for point in points])
50
51 def in_collision(self, self_center: np.ndarray,
52 other_rectangle: 'Rectangle',
53 other_center: np.ndarray) -> bool:
54 """check if two rectangles intersects (in collision)
55
56 Args:
57 other_rectangle (Rectangle): another rectangle
58
59 Returns:
60 bool: True if two rectangle intersects, False otherwise
61 """
62 self_vertexes = self.get_vertexes(self_center)
63 other_vertexes = other_rectangle.get_vertexes(other_center)
64
65 # first use AABB to filter impossible cases
66 self_x_max, self_y_max = np.max(self_vertexes, axis=0)
67 self_x_min, self_y_min = np.min(self_vertexes, axis=0)
68 other_x_max, other_y_max = np.max(other_vertexes, axis=0)
69 other_x_min, other_y_min = np.min(other_vertexes, axis=0)
70
71 if self_x_max < other_x_min or self_x_min > other_x_max or \
72 self_y_max < other_y_min or self_y_min > other_y_max:
73 return False
74
75 # use separate axis theorem check in-collision or not
76 return separate_axis_theorem(self_vertexes, other_vertexes)
77
78 def plotSelf(self, node: dpg.node, center: np.ndarray, ex: float,
79 ey: float):

Callers

nothing calls this directly

Calls 2

get_vertexesMethod · 0.95
separate_axis_theoremFunction · 0.90

Tested by

no test coverage detected