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])
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])
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)
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)