def collides(self, otherPos, otherBounds): diff = otherPos - self.pos dist = diff.get_length() if dist > Car.RADIUS * 2: return False bounds = self.getBounds() vec1 = bounds[0] - bounds[1] vec2 = otherBounds[0] - otherBounds[1] axis = [ vec1, vec1.perpendicular(), vec2, vec2.perpendicular() ] for vec in axis: (minA, maxA) = Vec2d.projectPoints(bounds, vec) (minB, maxB) = Vec2d.projectPoints(otherBounds, vec) leftmostA = minA <= minB overlap = False if leftmostA and maxA >= minB: overlap = True if not leftmostA and maxB >= minA: overlap = True if not overlap: return False return True