Ejemplo n.º 1
0
 def test_quaternion_vector_mult(self):
     self.assertAlmostEqual((1, 0, 0), quaternion_vector_mult((0, 0, 0, 1), (1, 0, 0)))
     self.assertAlmostEqual((0, 1, 0), quaternion_vector_mult((0, 0, 0, 1), (0, 1, 0)))
     self.assertAlmostEqual((0, 0, 1), quaternion_vector_mult((0, 0, 0, 1), (0, 0, 1)))
     q = quaternion_axis_angle((1, 0, 0), math.pi)
     self.assertAlmostEqual((1, 0, 0), quaternion_vector_mult(q, (1, 0, 0)))
     self.assertAlmostEqual((0, -1, 0), quaternion_vector_mult(q, (0, 1, 0)))
     self.assertAlmostEqual((0, 0, -1), quaternion_vector_mult(q, (0, 0, 1)))
Ejemplo n.º 2
0
 def test_quaternion_axis_angle(self):
     self.assertAlmostEqual((0, 0, 0, 1), quaternion_axis_angle((1, 0, 0), 0))
     self.assertAlmostEqual((0, 0, 0, 1), quaternion_axis_angle((0, 1, 0), 0))
     self.assertAlmostEqual((0, 0, 0, 1), quaternion_axis_angle((0, 0, 1), 0))
     self.assertAlmostEqual((0, 0, 0, -1), quaternion_axis_angle((1, 0, 0), 2 * math.pi))
     self.assertAlmostEqual((0, 0, 0, -1), quaternion_axis_angle((0, 1, 0), 2 * math.pi))
     self.assertAlmostEqual((0, 0, 0, -1), quaternion_axis_angle((0, 0, 1), 2 * math.pi))
Ejemplo n.º 3
0
 def test_quaternion_vector_mult(self):
     self.assertAlmostEqual((1, 0, 0),
                            quaternion_vector_mult((0, 0, 0, 1), (1, 0, 0)))
     self.assertAlmostEqual((0, 1, 0),
                            quaternion_vector_mult((0, 0, 0, 1), (0, 1, 0)))
     self.assertAlmostEqual((0, 0, 1),
                            quaternion_vector_mult((0, 0, 0, 1), (0, 0, 1)))
     q = quaternion_axis_angle((1, 0, 0), math.pi)
     self.assertAlmostEqual((1, 0, 0), quaternion_vector_mult(q, (1, 0, 0)))
     self.assertAlmostEqual((0, -1, 0),
                            quaternion_vector_mult(q, (0, 1, 0)))
     self.assertAlmostEqual((0, 0, -1),
                            quaternion_vector_mult(q, (0, 0, 1)))
Ejemplo n.º 4
0
 def test_quaternion_axis_angle(self):
     self.assertAlmostEqual((0, 0, 0, 1), quaternion_axis_angle((1, 0, 0),
                                                                0))
     self.assertAlmostEqual((0, 0, 0, 1), quaternion_axis_angle((0, 1, 0),
                                                                0))
     self.assertAlmostEqual((0, 0, 0, 1), quaternion_axis_angle((0, 0, 1),
                                                                0))
     self.assertAlmostEqual((0, 0, 0, -1),
                            quaternion_axis_angle((1, 0, 0), 2 * math.pi))
     self.assertAlmostEqual((0, 0, 0, -1),
                            quaternion_axis_angle((0, 1, 0), 2 * math.pi))
     self.assertAlmostEqual((0, 0, 0, -1),
                            quaternion_axis_angle((0, 0, 1), 2 * math.pi))