Formula to get a control point closest for a given point what belongs to this quadratic curve We have a quadratic bezier curve, with control point A (red start), control point B (red end), and yellow point X what belongs to the curve and what you actually "drag" - so it should be the closest point to the missing control point C (blue) what forms the curve. What is a formula getC(A,B,X) to calculate it?
drawing http://www.freeimagehosting.net/newuploads/d89e6.gif
A popular solution is when we think that X corresponds to t=1/2 for calculating C is not giving a nice result.
The concept is explained on this thread. But still I can't figure out the final formula for calculating C from it - having difficulty to understand the "orthogonality relation"
Thanks for any help!
 A: For simplicity of derivation, choose a coordinate system such that $\vec{X}$ is the origin.
The quadratic curve between $\vec{A}$ and $\vec{B}$ has the parametrization:
$$[0,1] \ni s \quad\mapsto\quad \vec{\gamma}(s) = (1-s)^2 \vec{A} + s^2 \vec{B} + 2s(1-s)\vec{C}$$
Since $\vec{X}$ lies on the quadratic curve, for some $t \in [0,1]$,
$\vec{\gamma}(t) = \vec{X} = \vec{0}$. This implies
$$\vec{C} = -\frac12 \left( \lambda^{-1} \vec{A} + \lambda \vec{B} \right)
\quad\text{ where }\quad \lambda = \frac{t}{1-t}.$$
So the problem of locating $\vec{C}$ reduces to the problem of figuring out the parametrization parameter $t$ for $\vec{X}$.
The tangent vector for the quadratic curve at $X$ is given by:
$$\gamma'(t) = \left.\frac{d\vec{\gamma}(s)}{ds}\right|_{s=t} = -2(1-t)\vec{A} + 2t\vec{B} + 2(1-2t)\vec{C} $$
Notice
$$\lambda = \frac{t}{1-t} \implies t = \frac{\lambda}{1+\lambda},\;\;1 - t = \frac{1}{1+\lambda} \;\;\text{ and }\;\; 1 - 2t = \frac{1-\lambda}{1+\lambda}$$
We find
$$ \gamma'(t) = -\frac{2}{1+\lambda}\vec{A} + \frac{2\lambda}{1+\lambda} \vec{B} - \frac{1 - \lambda}{1+\lambda}
\left( \lambda^{-1} \vec{A} + \lambda \vec{B} \right)
= \lambda \vec{B} - \lambda^{-1}\vec{A}
$$
The condition that $\vec{X}$ is the point on $\vec{\gamma}(s)$ closest to $\vec{C}$ can be expressed as:
$$\gamma'(t)  \cdot \vec{C} = 0
\quad\iff\quad
\left( \lambda^2 \vec{B} - \vec{A} \right) \cdot \left( \lambda^2 \vec{B} + \vec{A} \right) =
\lambda^4 R_B^2 - R_A^2 = 0
$$
where $R_A = |\vec{A}| $ and $R_B = |\vec{B}|$.
This give us
$$\lambda = \sqrt{R_A/R_B} 
\quad\implies\quad\vec{C} = -\frac{\sqrt{R_AR_B}}{2}\left( \frac{\vec{A}}{R_A} + \frac{\vec{B}}{R_B} \right)$$
Update
In the general case when $\vec{X}$ is not the origin, let 
$$\vec{A} = (A_x,A_y),\;\;\vec{B} = (B_x,B_y),\;\;\vec{C} = (C_x,C_y),\quad\text{ and }\quad \vec{X} = (X_x,X_y).$$
The distances of $\vec{A}$, $\vec{B}$ from $\vec{X}$ become
$$\begin{cases}
R_A = & \sqrt{(A_x - X_x)^2 + (A_y - X_y)^2}\\
R_B = & \sqrt{(B_x-X_x)^2 + (B_y-X_y)^2},
\end{cases}$$
and the coordinates of $\vec{C}$ turns into:
$$\begin{cases}
C_x = & X_x - 
\frac{\sqrt{R_A R_B}}{2}\left(\frac{A_x - X_x}{R_A} + \frac{B_x - X_x}{R_B}\right)\\
\\
C_y = & X_y -
\frac{\sqrt{R_A R_B}}{2}\left(\frac{A_y - X_y}{R_A} + \frac{B_y - X_y}{R_B}\right)
\end{cases}$$
A: An addendum to Achille Hui's fine solution (which is too long for a comment):
Let $\vec{U}$ and $\vec{V}$ be unit vectors in the directions of $\vec{X} - \vec{A}$ and 
$\vec{X} - \vec{B}$ respectively. Also, let $h = \Vert{\vec{X} - \vec{A}}\Vert$ and 
$k = \Vert{\vec{X} - \vec{B}}\Vert$. My $h$ and $k$ are Achille's $R_A$ and $R_B$ respectively. Then we have $\vec{X} - \vec{A} = h\vec{U}$ and $\vec{X} - \vec{B} = k\vec{V}$.
Achille showed that
$$
\vec{C} = \vec{X} + \frac12\sqrt{hk}(\vec{U} + \vec{V})
$$
But the vector $\vec{U} + \vec{V}$ is along the bisector of the lines $AX$ and $BX$, so, we get a nice geometric result: the middle control point $\vec{C}$ of the "optimal" curve lies on the bisector of the lines $AX$ and $BX$.
Also, the first derivative vector of the optimal curve at the point $\vec{X}$ is given by
$$
\gamma'(t) = \sqrt{hk}(\vec{U} - \vec{V})
$$
The vector $\vec{U} - \vec{V}$ is along the other bisector of the lines $AX$ and $BX$, so, we get another nice geometric result: the tangent vector of the "optimal" curve is parallel to the bisector of the lines $AX$ and $BX$. 
In aircraft lofting departments, there are people who construct parabolas (and other conic section curves) all day long. I wonder if they use this construction to get a "nice" parabola through three given points. I'll ask, next time I get a chance.
Here's a picture illustrating the geometry:

A: My approach would be along the lines of:


*

*Find the slope of the tangent line at any point along the quadratic curve

*Find the slope of the line from any point on the curve to the blue control point

*Then pick a point from step 2 that gives you a slope that is orthogonal (i.e. perpendicular) to the slope of the tangent line at that same point


Remember that two slopes are orthogonal if their product is -1.
A: Actually the bisector thing is a beautiful found I did at 2012 also at my paper that cover that theme “Quadratic bezier through three points” and something related of what I call “equivalent quadratic bezier”. Hope you found it interesting
https://microbians.com/math/Gabriel_Suchowolski_Quadratic_bezier_through_three_points_and_the_-equivalent_quadratic_bezier_(theorem)-.pdf
also had some more info on quadratic offseting and examples here https://microbians.com/mathcode

