def quat2angle_axis(quat, identity_thresh=None):
 (w, x, y, z) = quat
 vec = np.asarray([x, y, z])
 if (identity_thresh is None):
  try:
   identity_thresh = (np.finfo(vec.dtype).eps * 3)
  except ValueError:
   identity_thresh = (FLOAT_EPS * 3)
 n = math.sqrt((((x * x) + (y * y)) + (z * z)))
 if (n < identity_thresh):
  return (0.0, np.array([1.0, 0, 0]))
 return ((2 * math.acos(w)), (vec / n))

def quat2angle_axis ( quat , identity_thresh = None ) : ( w , x , y , z ) = quat vec = np . asarray ( [ x , y , z ] ) if ( identity_thresh is None ) : try : identity_thresh = ( np . finfo ( vec . dtype ) . eps * 3 ) except ValueError : identity_thresh = ( FLOAT_EPS * 3 ) n = math . sqrt ( ( ( ( x * x ) + ( y * y ) ) + ( z * z ) ) ) if ( n < identity_thresh ) : return ( 0.0 , np . array ( [ 1.0 , 0 , 0 ] ) ) return ( ( 2 * math . acos ( w ) ) , ( vec / n ) )
convert quaternion to rotation of angle around axis parameters quat : 4 element sequence w .