(rmat)
Converts a 3x3 rotation matrix to XYX euler angles.
Converts a 3x3 rotation matrix to XYX euler angles.
Converts a 3x3 rotation matrix to XYX euler angles .
def _rmat_to_euler_xyx(rmat):
  """Converts a 3x3 rotation matrix to XYX euler angles."""
  # | r00 r01 r02 |   |  cy      sy*sx1               sy*cx1             |
  # | r10 r11 r12 | = |  sy*sx0  cx0*cx1-cy*sx0*sx1  -cy*cx1*sx0-cx0*sx1 |
  # | r20 r21 r22 |   | -sy*cx0  cx1*sx0+cy*cx0*sx1   cy*cx0*cx1-sx0*sx1 |

  if rmat[0, 0] < 1.0:
    if rmat[0, 0] > -1.0:
      y = np.arccos(_clip_within_precision(rmat[0, 0], -1., 1.))
      x0 = np.arctan2(rmat[1, 0], -rmat[2, 0])
      x1 = np.arctan2(rmat[0, 1], rmat[0, 2])
      return np.array([x0, y, x1])
    else:
      # Not a unique solution:  x1_angle - x0_angle = atan2(-r12,r11)
      y = np.pi
      x0 = -np.arctan2(-rmat[1, 2], rmat[1, 1])
      x1 = 0.0
      return np.array([x0, y, x1])
  else:
    # Not a unique solution:  x1_angle + x0_angle = atan2(-r12,r11)
    y = 0.0
    x0 = -np.arctan2(-rmat[1, 2], rmat[1, 1])
    x1 = 0.0
    return np.array([x0, y, x1])
def _rmat_to_euler_xyx ( rmat ) : # | r00 r01 r02 |   |  cy      sy*sx1               sy*cx1             | # | r10 r11 r12 | = |  sy*sx0  cx0*cx1-cy*sx0*sx1  -cy*cx1*sx0-cx0*sx1 | # | r20 r21 r22 |   | -sy*cx0  cx1*sx0+cy*cx0*sx1   cy*cx0*cx1-sx0*sx1 | if rmat [ 0 , 0 ] < 1.0 : if rmat [ 0 , 0 ] > - 1.0 : y = np . arccos ( _clip_within_precision ( rmat [ 0 , 0 ] , - 1. , 1. ) ) x0 = np . arctan2 ( rmat [ 1 , 0 ] , - rmat [ 2 , 0 ] ) x1 = np . arctan2 ( rmat [ 0 , 1 ] , rmat [ 0 , 2 ] ) return np . array ( [ x0 , y , x1 ] ) else : # Not a unique solution:  x1_angle - x0_angle = atan2(-r12,r11) y = np . pi x0 = - np . arctan2 ( - rmat [ 1 , 2 ] , rmat [ 1 , 1 ] ) x1 = 0.0 return np . array ( [ x0 , y , x1 ] ) else : # Not a unique solution:  x1_angle + x0_angle = atan2(-r12,r11) y = 0.0 x0 = - np . arctan2 ( - rmat [ 1 , 2 ] , rmat [ 1 , 1 ] ) x1 = 0.0 return np . array ( [ x0 , y , x1 ] )