For an open source cad software called FreeCAD. In 2d editor I'm making the snapping feature for parabolas curves.
There is an parabola, the user put the mouse pointer close to it. So we have the point A, which is close to the parabola, but not exactly on it. I need to calculate the coordinates of the point B which is on the parabola close to A. (then the point B is used to override the mouse coordinates, such that the parabolais exactly under the mouse pointer).

Do you know how to calculate the point B ?
Thanks !
PS: Here is the same question but for hyperbola: Calculate a point on an hyperbola from a nearby point.

The first step is to generate the implicit equation of the parabola, i.e. find the equation in the form
$ A x^2 + B x y + C y^2 + D x + E y + F = 0 $
To do that, starting from the vertex $V$ and the focus $F$, compute the unit vector
$ u_2 = \dfrac{F - V}{\| F - V \| } $
And calculate the focal distance $p = \| F - V \| $
And finally calculate a unit vector $u_1$ that is perpendicular to $u_2$. Then the parametric equation of the parabola is
$ r = V + t u_1 + \dfrac{1}{4 p} t^2 u_2 $
The vector $u_1$ is computed from $u_2$ as follows:
$u_{1x} = u_{2 y} $
$u_{1y} = - u_{2 x} $
Let
$(x', y') = t u_1 + \dfrac{1}{4p} t^2 u_2 = [u_1, u_2] [ t, \dfrac{1}{4p} t^2]^T $
Let $U = [u_1, u_2]$, note that since $u_1, u_2$ are unit vectors then $U$ is a rotation matrix.
So now we have
$ (x', y') = U (x'', y'') = U [t, \dfrac{1}{4p} t^2 ]^T $
The equation governing $x''$ and $y''$ is $ y'' = \dfrac{1}{4p} x''^2 $
So
$ [x'', y''] Q \begin{bmatrix} x'' \\ y'' \end{bmatrix} + \begin{bmatrix} 0 && - 1 \end{bmatrix} \begin{bmatrix} x'' \\ y'' \end{bmatrix} = 0 $
where $Q = \begin{bmatrix} \dfrac{1}{4p} && 0 \\ 0 && 0 \end{bmatrix} $
But $[x'', y'']^T = U^{-1} [x', y']^T $, so
$ (r - V)^T U Q U^T (r - V) + b^T U^T (r - V) = 0 $
where $b = [0, -1]^T $
This last equation is the equation of the parabola in general format.
Now, we begin finding the closest point $(x_2, y_2)$ on the parabola to a given point $(x_1, y_1)$ that is not on the parabola.
The first equation that $(x_2, y_2)$ has to satisfy is
$ A x_2^2 + B x_2 y_2 + C y_2^2 + D x_2 + E y_2 + F = 0 $
The gradient of this function of two variables is given by
$ \nabla = \begin{bmatrix} 2 A x_2 + B y_2 + D \\ B x_2 + 2 C y_2 + E \end{bmatrix} $
And we want this gradient to have the same direction as $(x_2 - x_1, y_2 - y_1) $
So
$( 2 A x_2 + B y_2 + D , B x_2 + 2 C y_2 + E ) = \alpha (x_2 - x_1, y_2 - y_1 ) $
Eliminating $\alpha$ by dividing the $y$ coordinate by the $x$ coordinate,
$ \dfrac{y_2 - y_1}{x_2 - x_1} = \dfrac{ B x_2 + 2 C y_2 + E }{2 A x_2 + B y_2 + D } $
Cross multiplying,
$ (y_2 - y_1)(2 A x_2 + B y_2 + D) = (x_2 - x_1) (B x_2 + 2 C y_2 + E ) $
Now we have two quadratic equations in the two unknowns $x_2$ and $y_2$. These can be found using the Newton-Raphson root finder.
The following figure shows a sample parabola with a given point off the parabola, and the found point that is closest to it on the parabola.
Below, I've listed the whole program (written in Visual Basic for Applications)