def getPoints( self ) -> Tuple[Tuple[float, float], Tuple[float, float], Tuple[float, float]]: p = [0, 0, 0] p[0] = rotatePoint(-self.sizeX // 2, -self.sizeY // 2, self.angle) p[1] = rotatePoint(-self.sizeX // 2, self.sizeY // 2, self.angle) p[2] = rotatePoint(self.sizeX // 2, 0, self.angle) for x in range(3): p[x] = (p[x][0] + self.posX, p[x][1] + self.posY) return p[0], p[1], p[2]
def followMouse(self, deltaTime, mosePos): N = 10 center = (0, 0) for _ in range(N): o = orient(center, rotatePoint(10, 0, self.angle), (mosePos[0], mosePos[1]), 0) if o == -1: self.rotateLeft(deltaTime / N) elif o == 1: self.rotateRight(deltaTime / N)
def RotateContour(X, Y, rotation, centroid): ''' X and Y are lists of coordinates for a closed contour taken from a shapefile ''' rxs = [] rys = [] for nx, ny in zip(X, Y): rx, ry = rotatePoint(centroid, (nx, ny), rotation + 180.) rxs.append(rx) rys.append(ry) return rxs, rys
def nextCycle(self, deltaTime: float, posX: float, posY: float) -> None: self.correctCoolDown(deltaTime) N=10 for _ in range(1,N): p2 = self.getPoint() center = (self.posX + self.sizeX // 2, self.posY + self.sizeY // 2) o = orient(center, p2, (posX, posY)) if o == -1: self.rotateLeft(deltaTime/N) elif o == 1: self.rotateRight(deltaTime/N) else: rotatedRight = rotatePoint(0, 10, self.angle) if orient((self.posX,self.posY),(self.posX+rotatedRight[0],self.posY+rotatedRight[1]),(posX,posY))==1: self.rotateRight(deltaTime/N)
def getPoints(self) -> tuple[tuple[float, float]:5]: """return point of rocket, include current rotation""" return ((x + self.posX, y + self.posY) for p in self.pointsOrigin for x, y in rotatePoint(p[0], p[1], self.angle))
def getPoint(self) -> tuple[float, float]: x, y = rotatePoint(self.pointsOrigin[0][0], self.pointsOrigin[0][1], self.angle) return x + self.posX, y + self.posY
def getPoint(self) -> tuple[float, float]: p = rotatePoint(10, 0, self.angle) return p[0] + self.posX + self.sizeX // 2, p[1] + self.posY + self.sizeY // 2
def canShoot(self, posX: float, posY: float): p2 = self.getPoint() rotatedRight = rotatePoint(0,10,self.angle) return distPointFromLine(*twoPointToLine((self.posX + self.sizeX // 2, self.posY + self.sizeY // 2), p2), posX, posY) < self.disLim and orient((self.posX,self.posY),(self.posX+rotatedRight[0],self.posY+rotatedRight[1]),(posX,posY))==-1