def quaternion_inv(q):
    """
    Inverse of quaternion q
    Args:
            q: (qw, qx, qy, qz)
    """
    w, x, y, z = q
    d = w*w + x*x + y*y + z*z
    q_inv = (w/d, -x/d, -y/d, -z/d)
    return q_inv