def test_sheppards_method_same_result():
     for i in range(
             30
     ):  # this is a quick and poor way to check that sheppard's method works for all 4 cases
         dcm = ut.random_dcm()
         b1 = tr.dcm_to_quaternions(dcm)
         b2 = tr.sheppards_method(dcm)
         np.testing.assert_almost_equal(b1, b2)
 def test_mrp_valid_dcm():
     dcm1 = ut.random_dcm()
     b = tr.dcm_to_mrp(dcm1)
     dcm2 = tr.mrp_to_dcm(b)
     np.testing.assert_almost_equal(dcm2 @ dcm2.T, np.identity(3))
     np.testing.assert_almost_equal(np.linalg.det(dcm2), 1)
     for i in (0, 1, 2):
         np.testing.assert_almost_equal(np.linalg.norm(dcm2[i]), 1)
         np.testing.assert_almost_equal(np.linalg.norm(dcm2[:, i]), 1)
 def test_pvr_valid_dcm():
     dcm1 = ut.random_dcm()
     angle, e = tr.dcm_to_prv(dcm1)
     dcm2 = tr.prv_to_dcm(angle, e)
     np.testing.assert_almost_equal(dcm2 @ dcm2.T, np.identity(3))
     np.testing.assert_almost_equal(np.linalg.det(dcm2), 1)
     for i in (0, 1, 2):
         np.testing.assert_almost_equal(np.linalg.norm(dcm2[i]), 1)
         np.testing.assert_almost_equal(np.linalg.norm(dcm2[:, i]), 1)
 def test_mrp_reverse():
     dcm1 = ut.random_dcm()
     b = tr.dcm_to_mrp(dcm1)
     dcm2 = tr.mrp_to_dcm(b)
     np.testing.assert_almost_equal(dcm1, dcm2)
 def test_random_dcm_1():
     dcm = ut.random_dcm()
     np.testing.assert_almost_equal(dcm @ dcm.T, np.identity(3))
 def test_quaternions_reverse():
     dcm1 = ut.random_dcm()
     b = tr.dcm_to_quaternions(dcm1)
     dcm2 = tr.quaternions_to_dcm(b)
     np.testing.assert_almost_equal(dcm1, dcm2)
 def test_pvr_reverse():
     dcm1 = ut.random_dcm()
     angle, e = tr.dcm_to_prv(dcm1)
     dcm2 = tr.prv_to_dcm(angle, e)
     np.testing.assert_almost_equal(dcm1, dcm2)
 def test_random_dcm_3():
     dcm = ut.random_dcm()
     for i in (0, 1, 2):
         np.testing.assert_almost_equal(np.linalg.norm(dcm[i]), 1)
         np.testing.assert_almost_equal(np.linalg.norm(dcm[:, i]), 1)
 def test_random_dcm_2():
     dcm = ut.random_dcm()
     np.testing.assert_almost_equal(np.linalg.det(dcm), 1)