def quaternion_to_xaxis_yaxis(q):
    """Return the (xaxis, yaxis) unit vectors representing the orientation specified by a quaternion in x,y,z,w format."""

    x = q[0]
    y = q[1]
    z = q[2]
    w = q[3]

    xaxis = [ w*w + x*x - y*y - z*z,       2*(x*y + w*z),             2*(x*z - w*y) ]
    yaxis = [ 2*(x*y - w*z),               w*w - x*x + y*y - z*z,     2*(y*z + w*x) ]

    return xaxis, yaxis