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

Class RecCollide

limsim/utils/trajectory.py:55–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54
55class RecCollide:
56
57 def __init__(self, recA: Rectangle, recB: Rectangle) -> None:
58 self.recA = recA
59 self.recB = recB
60
61 def rotateTransCritic(self, A: Rectangle, B: Rectangle) -> np.ndarray:
62 aBase: np.ndarray = A.iRotate.dot(A.corners.T)
63 aBase = aBase.T
64 aPos = A.iRotate.dot(A.center)
65
66 bBase: np.ndarray = A.iRotate.dot(B.corners.T)
67 bBase = bBase.T
68 bPos = A.iRotate.dot(B.center)
69
70 posTotal = abs(bPos - aPos)
71 rotateC = A.iRotate.dot(B.rotateMat)
72 bh = np.array([abs(item) for item in rotateC
73 ]).dot(np.array([B.length / 2, B.width / 2]))
74
75 return posTotal - bh - np.array([A.length / 2, A.width / 2])
76
77 def isCollide(self) -> bool:
78 critic1 = self.rotateTransCritic(self.recA, self.recB)
79
80 if critic1[0] < 0 and critic1[1] < 0:
81 critic2 = self.rotateTransCritic(self.recB, self.recA)
82 if critic2[0] < 0 and critic2[1] < 0:
83 return True
84 return False
85
86
87@dataclass

Callers 2

VTCollisionCheckMethod · 0.90
VTCollisionCheckMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected