Пример #1
0
    def test_rotate(self):
        q = Quaternion.from_axis_angle(numpy.array([0, 1, 0]), math.pi / 2.0)
        v = q.rotate((1, 0, 0))

        self.assertAlmostEqual(0, v[0])
        self.assertAlmostEqual(0, v[1])
        self.assertAlmostEqual(-1, v[2])
Пример #2
0
    def test_rotate(self):
        q = Quaternion.from_axis_angle(numpy.array([0, 1, 0]), math.pi / 2.0)
        v = q.rotate((1, 0, 0))

        self.assertAlmostEqual( 0, v[0])
        self.assertAlmostEqual( 0, v[1])
        self.assertAlmostEqual(-1, v[2])
Пример #3
0
    def test_from_axis_angle(self):
        theta = math.pi / 5.0

        c = math.cos(theta / 2.0)
        s = math.sin(theta / 2.0)
        q = Quaternion.from_axis_angle(numpy.array([1, -1, 1]), theta)

        self.assertAlmostEqual(c, q.w)
        self.assertAlmostEqual(s * math.sqrt(1.0 / 3.0), q.x)
        self.assertAlmostEqual(-s * math.sqrt(1.0 / 3.0), q.y)
        self.assertAlmostEqual(s * math.sqrt(1.0 / 3.0), q.z)
Пример #4
0
    def test_from_axis_angle(self):
        theta = math.pi / 5.0

        c = math.cos(theta / 2.0)
        s = math.sin(theta / 2.0)
        q = Quaternion.from_axis_angle(numpy.array([1, -1, 1]), theta)

        self.assertAlmostEqual( c, q.w)
        self.assertAlmostEqual( s * math.sqrt(1.0 / 3.0), q.x)
        self.assertAlmostEqual(-s * math.sqrt(1.0 / 3.0), q.y)
        self.assertAlmostEqual( s * math.sqrt(1.0 / 3.0), q.z)