def dcmtoquat(dcm):
    """Convert DCM to quaternion
    
    This function will convert a rotation matrix, also called a direction
    cosine matrix into the equivalent quaternion.

    Parameters:
    ----------
    dcm - (3,3) numpy array
        Numpy rotation matrix which defines a rotation from the b to a frame

    Returns:
    --------
    quat - (4,) numpy array
        Array defining a quaterion where the quaternion is defined in terms of
        a vector and a scalar part.  The vector is related to the eigen axis
        and equivalent in both reference frames [x y z w]
    """
    quat = np.zeros(4)
    quat[-1] = 1/2*np.sqrt(np.trace(dcm)+1)
    quat[0:3] = 1/4/quat[-1]*vee_map(dcm-dcm.T)

    return quat