Calculate a point on an hyperbola from a nearby point. I am working on an open source cad software called FreeCAD. In the sketcher I'm making the snapping feature for hyperbolas curves.
There is an hyperbola, the user put the mouse pointer close to it. So we have the point A, which is close to the hyperbola, but not exactly on it. I need to calculate the coordinates of the point B which is on the hyperbola. (then the point B is used to override the mouse coordinates, such that the hyperbola is exactly under the mouse pointer).

Base::Vector2d A, centerPoint,  majorAxis, minorAxis are known.

//This is appantly wrong : 
Base::Vector2d vec = A - centerPoint;
double U = atanh(vec.y / minorAxis.Length()) + acosh(vec.x / majorAxis.Length());

//This seems to be OK as it create points on the hyperbola :
B = centerPoint + majorAxis * cosh(U) + minorAxis * sinh(U);

The last line calculates points that are on the hyperbola. So it seems OK, if so the U that is fed into would be wrong.
Do you know how to calculate the point B ? Thanks !
 A: Big thanks to Glorious Erin to solve this.
Here is the code in C++ for reference for future readers :
const Part::GeomArcOfHyperbola* hyperbola = static_cast<const Part::GeomArcOfHyperbola*>(geo);
Base::Vector2d centerPoint = Base::Vector2d(hyperbola->getCenter().x, hyperbola->getCenter().y);
Base::Vector2d majorAxis = Base::Vector2d(hyperbola->getMajorAxisDir().x, hyperbola->getMajorAxisDir().y);
Base::Vector2d minorAxis = Base::Vector2d(hyperbola->getMajorAxisDir().y, - hyperbola->getMajorAxisDir().x);

Base::Vector2d xvec, yvec, dvec;
double jac[2][2], jacinv[2][2];
double det;
double a = hyperbola->getMajorRadius();
double b = hyperbola->getMinorRadius();

//First we need to know the coordinates of pointToOverride in the coordinate system of the hyperbola.
Base::Vector2d p = pointToOverride - centerPoint;
Base::Vector2d px, py;
px.ProjectToLine(p, majorAxis);
py.ProjectToLine(p, minorAxis);
bool reverseY = py * minorAxis < 0;
p = Base::Vector2d(px.Length(), py.Length());

//Initialization xvec
xvec = p;

bool success = false;
for (int i = 0; i < 100; ++i) {  // Maximum 100 iterations
    //Compute the nonlinear functions yvec
    yvec.x = xvec.x * xvec.x / (a * a) - xvec.y * xvec.y / (b * b) - 1;
    yvec.y = a * a * (xvec.y - p.y) * xvec.y + b * b * (xvec.x - p.x) * xvec.x;

    if (yvec.Length() < 1e-7) {
        success = true;
        break;
    }

    //Compute the jacobian
    jac[0][0] = 2 * xvec.x / (a * a);
    jac[0][1] = - 2 * xvec.y / (b * b);
    jac[1][0] = a * a * (2 * xvec.y - p.y);
    jac[1][1] = b * b * (2 * xvec.x - p.x);

    //find the inverse of the jacobian matrix
    det = jac[0][0] * jac[1][1] - jac[0][1] * jac[1][0];
    jacinv[0][0] = jac[1][1] / det;
    jacinv[1][1] = jac[0][0] / det;
    jacinv[0][1] = -jac[0][1] / det;
    jacinv[1][0] = -jac[1][0] / det;

    //multiply jacinv by  yvec
    dvec.x = jacinv[0][0] * yvec.x + jacinv[0][1] * yvec.y;
    dvec.y = jacinv[1][0] * yvec.x + jacinv[1][1] * yvec.y;

    if (dvec.Length() < 1e-7) {
        success = true;
        break;
    }

    //update xvec
    xvec = xvec - dvec;
}

if (success) {
    pointToOverride = centerPoint + xvec.x * majorAxis + (reverseY ? -1 : 1) * xvec.y * minorAxis;
}

