def test_invert_rotation(self): assert rotate(-45) == matrix_inverse(rotate(45)) assert rotate(90) == matrix_inverse(rotate(-90)) assert identity() == matrix_multiply(rotate(45), rotate(-45)) assert identity() == matrix_multiply(rotate(-45), rotate(45)) assert identity() == matrix_multiply(rotate(90), rotate(-90)) assert identity() == matrix_multiply(rotate(-90), rotate(90))
def test_invert_identity(self): I = identity() assert I == matrix_inverse(I)
def test_invert_translate(self): assert translate(-3, -5) == matrix_inverse(translate(3, 5)) assert translate(-2, 1) == matrix_inverse(translate(2, -1))
def test_invert_scale(self): assert scale(2, 4) == matrix_inverse(scale(0.5, 0.25)) assert scale(0.1, 8) == matrix_inverse(scale(10, 0.125)) assert identity() == matrix_multiply(scale(2, 4), scale(0.5, 0.25)) assert identity() == matrix_multiply(scale(0.1, 8), scale(10, 0.125))
def test_invert_identity(self): ident = identity() assert ident == matrix_inverse(ident)