code: def preRotate(self, theta):
          
          while theta < 0: theta += 360
          while theta >= 360: theta -= 360
          epsilon = 1e-5
          if abs(0 - theta) < epsilon:
              pass
  
          elif abs(90.0 - theta) < epsilon:
              a = self.a
              b = self.b
              self.a = self.c
              self.b = self.d
              self.c = -a
              self.d = -b
  
          elif abs(180.0 - theta) < epsilon:
              self.a = -self.a
              self.b = -self.b
              self.c = -self.c
              self.d = -self.d
  
          elif abs(270.0 - theta) < epsilon:
              a = self.a
              b = self.b
              self.a = -self.c
              self.b = -self.d
              self.c = a
              self.d = b
  
          else:
              rad = math.radians(theta)
              s = round(math.sin(rad), 12)
              c = round(math.cos(rad), 12)
              a = self.a
              b = self.b
              self.a = c * a + s * self.c
              self.b = c * b + s * self.d
              self.c =-s * a + c * self.c
              self.d =-s * b + c * self.d
  
          return self
docs: Calculate pre rotation and replace current matrix.