import math


def rotation_matrix_to_xzy_euler(rotation_matrix):
    """
    Extracts XZY euler angles from given rotation matrix
    """

    sy = math.sqrt(rotation_matrix[0][0] * rotation_matrix[0][0] + rotation_matrix[2][0] * rotation_matrix[2][0])
    singular = sy < 1e-7
    if not singular:
        x = math.degrees(math.atan2(-rotation_matrix[1][2], rotation_matrix[1][1]))
        y = math.degrees(math.atan2(rotation_matrix[1][0], sy))
        z = math.degrees(math.atan2(-rotation_matrix[2][0], rotation_matrix[0][0]))
    else:
        x = math.degrees(math.atan2(-rotation_matrix[1][2], rotation_matrix[1][1]))
        y = math.degrees(math.atan2(rotation_matrix[1][0], sy))
        z = 0

    return [x, y, z]