import torch


def convert_ax_angle_to_quat(ax, ang):
    """
    Convert Euler angles to quaternion.
    """
    qw = torch.cos(ang/2)
    qx = ax[0] * torch.sin(ang/2)
    qy = ax[1] * torch.sin(ang/2)
    qz = ax[2] * torch.sin(ang/2)
    quat = torch.stack([qw, qx, qy, qz], dim=1)
    return quat