import numpy as np


def rot_to_angle(rot):
    return np.arccos(0.5*np.trace(rot)-0.5)


def rot_to_heading(rot):
    # This function calculates the heading angle of the rot matrix w.r.t. the y-axis
    new_rot = rot[0:3:2, 0:3:2]  # remove the mid row and column corresponding to the y-axis
    new_rot = new_rot/np.linalg.det(new_rot)
    return np.arctan2(new_rot[1, 0], new_rot[0, 0])

[((12, 11, 12, 51), 'numpy.arctan2', 'np.arctan2', ({(12, 22, 12, 35): 'new_rot[1, 0]', (12, 37, 12, 50): 'new_rot[0, 0]'}, {}), '(new_rot[1, 0], new_rot[0, 0])', True, 'import numpy as np\n'), ((11, 22, 11, 44), 'numpy.linalg.det', 'np.linalg.det', ({(11, 36, 11, 43): 'new_rot'}, {}), '(new_rot)', True, 'import numpy as np\n'), ((5, 25, 5, 38), 'numpy.trace', 'np.trace', ({(5, 34, 5, 37): 'rot'}, {}), '(rot)', True, 'import numpy as np\n')]