def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.hw = hw = self.width / 2 self.hh = hh = self.height / 2 self.radius = hypot(hw, hh) # circumcircle; for collision detection self.inradius = min(hw, hh) # incircle; for collision detection self._relations = []
def __init__(self, position, heading, width, height): super().__init__('Rectangle', position, heading, width, height) self.position = position.toVector() self.heading = heading self.width = width self.height = height self.hw = hw = width / 2 self.hh = hh = height / 2 self.radius = hypot(hw, hh) # circumcircle; for collision detection self.corners = tuple(position.offsetRotated(heading, Vector(*offset)) for offset in ((hw, hh), (-hw, hh), (-hw, -hh), (hw, -hh))) self.circumcircle = (self.position, self.radius)
def __init__(self, position, heading, width, length, name=None): super().__init__(name, position, heading, width, length) self.position = position.toVector() self.heading = heading self.width = width self.length = length self.hw = hw = width / 2 self.hl = hl = length / 2 self.radius = hypot(hw, hl) # circumcircle; for collision detection self.corners = tuple( position.offsetRotated(heading, Vector(*offset)) for offset in ((hw, hl), (-hw, hl), (-hw, -hl), (hw, -hl))) self.circumcircle = (self.position, self.radius)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) import scenic.syntax.veneer as veneer # TODO improve? veneer.registerObject(self) self.hw = hw = self.width / 2 self.hh = hh = self.height / 2 self.radius = hypot(hw, hh) # circumcircle; for collision detection self.inradius = min(hw, hh) # incircle; for collision detection self.left = self.relativePosition(-hw, 0) self.right = self.relativePosition(hw, 0) self.front = self.relativePosition(0, hh) self.back = self.relativePosition(0, -hh) self.frontLeft = self.relativePosition(-hw, hh) self.frontRight = self.relativePosition(hw, hh) self.backLeft = self.relativePosition(-hw, -hh) self.backRight = self.relativePosition(hw, -hh) self.corners = (self.frontRight.toVector(), self.frontLeft.toVector(), self.backLeft.toVector(), self.backRight.toVector()) camera = self.position.offsetRotated(self.heading, self.cameraOffset) self.visibleRegion = SectorRegion(camera, self.visibleDistance, self.heading, self.viewAngle) self._relations = []