[Math] Formula to get a control point closest for a given point what belongs to this quadratic curve

bezier-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!

Best Answer

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: curve