def test_rotate(self): m = Matrix() # rotate 90 degrees CCW m = m.rotate_ccw(math.pi / 2) expected = [[0, -1, 0], [1, 0, 0], [0, 0, 1]] self.compareMatrix(m.matrix, expected) m2 = Matrix() m2 = m2.rotate_ccw(math.pi) expected2 = [[-1 , 0, 0], [0, -1, 0], [0, 0, 1]] self.compareMatrix(m2.matrix, expected2)
def test_combine(self): m = Matrix() # rotate 90 degrees CCW m = m.translate(x=4, y=-2) m = m.rotate_ccw(math.pi / 2) m = m.scale(scale_x=2, scale_y=3) expected = [[2, -1, 4], [1, 3, -2], [0, 0, 1]] self.compareMatrix(m.matrix, expected)