Пример #1
0
 def test_inverse_non_unit(self):
     q = [1, 2, 3, 4]
     result = quaternion.inverse(q)
     expected = quaternion.conjugate(q) / quaternion.length(q)
     np.testing.assert_almost_equal(result, expected, decimal=5)
Пример #2
0
 def test_length(self):
     result = quaternion.length([1., 1., 1., 1.])
     np.testing.assert_almost_equal(result, 2., decimal=5)
Пример #3
0
 def test_length_batch(self):
     result = quaternion.length([
         [0., 0., 0., 1.],
         [1., 1., 1., 1.],
     ])
     np.testing.assert_almost_equal(result, [1., 2.], decimal=5)
Пример #4
0
 def test_inverse_non_unit(self):
     q = [1, 2, 3, 4]
     result = quaternion.inverse(q)
     expected = quaternion.conjugate(q) / quaternion.length(q)
     np.testing.assert_almost_equal(result, expected, decimal=5)
Пример #5
0
 def test_length_identity(self):
     result = quaternion.length([0., 0., 0., 1.])
     np.testing.assert_almost_equal(result, 1., decimal=5)
Пример #6
0
 def test_length_batch(self):
     result = quaternion.length([
         [0., 0., 0., 1.],
         [1., 1., 1., 1.],
     ])
     np.testing.assert_almost_equal(result, [1., 2.], decimal=5)
Пример #7
0
 def test_length(self):
     result = quaternion.length([1., 1., 1., 1.])
     np.testing.assert_almost_equal(result, 2., decimal=5)
Пример #8
0
 def test_length_identity(self):
     result = quaternion.length([0., 0., 0., 1.])
     np.testing.assert_almost_equal(result, 1., decimal=5)
Пример #9
0
 def test_length(self):
     q = Quaternion.from_x_rotation(np.pi / 2.0)
     self.assertTrue(np.allclose(q.length, quaternion.length(q)))
Пример #10
0
 def test_length(self):
     q = Quaternion.from_x_rotation(np.pi / 2.0)
     self.assertTrue(np.allclose(q.length, quaternion.length(q)))