def rot_matrix_to_euler_angles(rot_matrix):

"""Returns the 3-1-3 Euler angles `phi`, `theta` and `psi` (using the

- x-convention) corresponding to the rotation matrix ~~`~~`rot_matrix`~~`~~, which

+ x-convention) corresponding to the rotation matrix `rot_matrix`, which

is a tuple of three 3-element tuples, where each one is a row (what is

Using the x-convention, the 3-1-3 Euler angles `phi`, `theta` and `psi`

- (around the Z, X and again the Z-axis) can be obtained as follows

+ (around the Z, X and again the Z-axis) can be obtained as follows::

phi = arctan2(A_{31}, A_{32})

psi = -arctan2(A_{13}, A_{23})

- http://en.wikipedia.org/wiki/Rotation_representation_(mathematics)#

- Rotation_matrix_.E2.86.94_Euler_angles

+ http://en.wikipedia.org/wiki/Rotation_representation_(mathematics)%23Rotation_matrix_.E2.86.94_Euler_angles