def project_inv(pt, proj_axis, a, v):
    """Returns the vector w in the surface's plane such that project(w) equals x.

    See http://stackoverflow.com/a/39008641/1706564

    :param pt: A two-dimensional point.
    :param proj_axis: The axis to project into.
    :param a: Distance to the origin for the plane to project into.
    :param v: Normal vector of the plane to project into.
    :returns: The transformed point.

    """
    w = list(pt)
    w[proj_axis:proj_axis] = [0.0]
    c = a
    for i in range(3):
        c -= w[i] * v[i]
    c /= v[proj_axis]
    w[proj_axis] = c
    return tuple(w)
