def makeInverseMatrix(self, grid): # first apply a negative translation by the rotCenter # then apply the rotation # then reverse the rotCenter centerVec = bdggeom.Vec2f(*grid.indexToWorld(*self.rotCenterIndices)) rotRad = 2 * math.pi / self.rotCount negTrans = bdggeom.makeTranslationMatrix(-centerVec.x, -centerVec.y) posTrans = bdggeom.makeTranslationMatrix(centerVec.x, centerVec.y) rotTrans = bdggeom.makeRotationMatrix(-rotRad) return posTrans.mulMat(rotTrans.mulMat(negTrans))
def appendTranslation(self, dx, dy): self.transformMatrix = bdggeom.makeTranslationMatrix(dx, dy).mulMat( self.transformMatrix)
def appendTranslation(self, dx, dy): trans = bdggeom.makeTranslationMatrix(dx, dy) self.gridToWorldTransform = trans.mulMat(self.gridToWorldTransform) invTrans = bdggeom.makeTranslationMatrix(-dx, -dy) self.worldToGridTransform = self.worldToGridTransform.mulMat(invTrans)
def makeInverseMatrix(self, grid): offsetVec = bdggeom.Vec2f(*grid.indexToWorld(*self.offset)) return bdggeom.makeTranslationMatrix(-offsetVec.x, -offsetVec.y)