예제 #1
0
    def test_call_happy_path(self):
        linear_map = LinearMap_3d_to_5d(
            ((1, 2, 3), (4, 5, 6), (7, 8, 9), (10, 11, 12), (13, 14, 15)))

        v3d = Vec3(1, 1, 1)

        expected_result = Vec5(6, 15, 24, 33, 42)

        self.assertEqual(linear_map(v3d), expected_result)
    def test_multiply_matrix_by_vector(self):
        m = Matrix_5x3((
            (1, 2, 3),
            (4, 5, 6),
            (7, 8, 9),
            (10, 11, 12),
            (13, 14, 15)
            ))

        v = Vec3(1, 1, 1)

        result = m * v
        self.assertEqual(result, Vec5(6, 15, 24, 33, 42))
 def test_add_between_classes_2(self):
     with self.assertRaises(
             TypeError,
             msg='should raise TypeError when not compatible class'):
         Vec3(1, 2, 3) + Vec2(1, 2)
 def test_eq_between_classes(self):
     self.assertFalse(Vec2(1, 2) == Vec3(1, 2, 3))
     self.assertFalse(Vec3(1, 2, 3) == Vec2(1, 2))
 def test_negate_vector(self):
     self.assertEqual(-Vec3(-1, 2, -3), Vec3(1, -2, 3))
 def random_vec3(self):
     return Vec3(self.random_scalar(), self.random_scalar(),
                 self.random_scalar())
 def test_zero_vector(self):
     self.assertEqual(Vec3.zero(), Vec3(0, 0, 0))
 def test_scalar_division(self):
     self.approx_equal_vec3(Vec3(10, -4.4, 1) / 2, Vec3(5, -2.2, 0.5))