def test_repr(self): mat = Matrix4(IDENTITY) v = repr(mat) self.assertGreater(len(v), 10) self.assertIn("Matrix4", v) mat = Matrix4([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) v = repr(mat) self.assertGreater(len(v), 20) self.assertIn("Matrix4", v) mat = Matrix4(ZEROS_16) v = repr(mat) self.assertGreater(len(v), 10) self.assertIn("Matrix4", v)
def test_inverse(self): mat = Matrix4([ 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, -0.0, 0.0, -0.0, 1.0, -0.0, 0.0, -0.0, -0.0, -10.0, 1.0, ]) self.assertEqual(mat * mat.inverse(), Matrix4(IDENTITY))
def test_look_at(self): res = Matrix4([ 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, -0.0, 0.0, -0.0, 1.0, -0.0, 0.0, -0.0, -0.0, -10.0, 1.0, ]) self.assertEqual( Matrix4.look_at(IVec(10, 0, 0), IVec(0, 0, 0), IVec(0, 0, 1)), res)
def test_bytes(self): mat = Matrix4(IDENTITY) b = mat.bytes() self.assertIsInstance(b, bytes) self.assertGreater(len(b), 15)
def test_multiply_notimpl(self): mat = Matrix4(ZEROS_16) with self.assertRaises(TypeError): 1 * mat with self.assertRaises(TypeError): mat * 1
def test_multiply_vector(self): mat = Matrix4(IDENTITY) vec = MVec(1, 2, 3, 1) self.assertEqual(mat * vec, vec)
def test_multiply_identity(self): mat1 = Matrix4(IDENTITY) mat2 = Matrix4(IDENTITY) mat3 = Matrix4(IDENTITY) self.assertEqual(mat1 * mat2, mat3)
def test_str(self): mat = Matrix4(IDENTITY) v = mat.__str__() self.assertGreater(len(v), 20)