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)
def test_length(self): result = quaternion.length([1., 1., 1., 1.]) np.testing.assert_almost_equal(result, 2., decimal=5)
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)
def test_length_identity(self): result = quaternion.length([0., 0., 0., 1.]) np.testing.assert_almost_equal(result, 1., decimal=5)
def test_length(self): q = Quaternion.from_x_rotation(np.pi / 2.0) self.assertTrue(np.allclose(q.length, quaternion.length(q)))