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

Class Rectangle

limsim/utils/trajectory.py:24–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23
24class Rectangle:
25
26 def __init__(self, center: list[float], length: float, width: float,
27 yaw: float) -> None:
28 self.center = np.array(center)
29 self.length = length
30 self.width = width
31 self.yaw = yaw
32 self.rotateMat = self.getRotateMat()
33 self.iRotate = np.linalg.inv(self.rotateMat)
34 self.sCorners = self.getSCorners()
35 self.corners = self.getCorners()
36
37 def getRotateMat(self) -> np.ndarray:
38 return np.array([[np.cos(self.yaw), -np.sin(self.yaw)],
39 [np.sin(self.yaw), np.cos(self.yaw)]],
40 dtype=np.float32)
41
42 # shape corners
43 def getSCorners(self) -> np.ndarray:
44 return np.array([[self.length / 2, self.width / 2],
45 [-self.length / 2, self.width / 2],
46 [-self.length / 2, -self.width / 2],
47 [self.length / 2, -self.width / 2]])
48
49 def getCorners(self) -> np.ndarray:
50 TRCorners = self.sCorners.T
51 rotCorners: np.ndarray = np.dot(self.rotateMat, TRCorners)
52 return rotCorners.T + self.center
53
54
55class RecCollide:

Callers 2

VTCollisionCheckMethod · 0.90
VTCollisionCheckMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected