from typing import List
import math


def euler_to_quaternion(roll: float = 0.0,
                        pitch: float = 0.0,
                        yaw: float = 0.0) -> List:
    """
    Convert orientation in euler angles (in terms of roll, pitch, yaw) here
    to quarternion.
    The order of rotation applied: roll -> pitch -> yaw

    Args:
        roll (float, optional): gives the bank angle. Defaults to 0.
        pitch (float, optional): gives the elevation. Defaults to 0.
        yaw (float, optional): gives the bearing. Defaults to 0.

    Returns:
        list: a list representing x y z w of quaternion.
    """
    # Abbreviations for the various angular functions
    cy = math.cos(yaw * 0.5)
    sy = math.sin(yaw * 0.5)
    cp = math.cos(pitch * 0.5)
    sp = math.sin(pitch * 0.5)
    cr = math.cos(roll * 0.5)
    sr = math.sin(roll * 0.5)

    # Quaternion
    x = cy * cp * sr - sy * sp * cr
    y = sy * cp * sr + cy * sp * cr
    z = sy * cp * cr - cy * sp * sr
    w = cy * cp * cr + sy * sp * sr

    return [x, y, z, w]