@@ -509,6 +509,26 @@ def test_tr2angvec(self):
509509 nt .assert_array_almost_equal (theta , 90 )
510510 nt .assert_array_almost_equal (v , np .r_ [0 , 1 , 0 ])
511511
512+ true_ang = 1.51
513+ true_vec = np .array ([0. , 1. , 0. ])
514+ eps = 1e-08
515+
516+ # show that tr2angvec works on true rotation matrix
517+ R = SO3 .Ry (true_ang )
518+ ang , vec = t3d .tr2angvec (R .A , check = True )
519+ nt .assert_equal (ang , true_ang )
520+ nt .assert_equal (vec , true_vec )
521+
522+ # check a rotation matrix that should fail
523+ badR = SO3 .Ry (true_ang ).A [:, :] + eps
524+ with self .assertRaises (ValueError ):
525+ t3d .tr2angvec (badR , check = True )
526+
527+ # run without check
528+ ang , vec = t3d .tr2angvec (badR , check = False )
529+ nt .assert_almost_equal (ang , true_ang )
530+ nt .assert_equal (vec , true_vec )
531+
512532 def test_print (self ):
513533 R = rotx (0.3 ) @ roty (0.4 )
514534 s = trprint (R , file = None )
@@ -779,7 +799,6 @@ def test_x2tr(self):
779799 x2tr (x , representation = "exp" ), transl (t ) @ r2t (trexp (gamma ))
780800 )
781801
782-
783802# ---------------------------------------------------------------------------------------#
784803if __name__ == "__main__" :
785804 unittest .main ()
0 commit comments