import math


def yaw_pitch_roll(q):
    """
    Calculate Euler angles from pyquaternion.
    Output: - `roll`: rotation about the new X-axis
            - `pitch`: rotation about the new Y-axis
            - `yaw`: rotation about the new Z-axis
    """
    q = q.normalised
    roll = math.atan2(2 * (q.w * q.x + q.y * q.z), 1 - 2 * (q.x ** 2 + q.y ** 2))
    pitch = math.asin(2 * (q.w * q.y - q.z * q.x))
    yaw = math.atan2(2 * (q.w * q.z + q.x * q.y), 1 - 2 * (q.y ** 2 + q.z ** 2))
    return yaw, pitch, roll