Cubic Bezier curve tangent to Circle I have a cubic Bezier curve (4 points: P0, P1, P2, P3) :
$$B(t)=((1-t)^3P_0+3t(1-t)^2P_1+3t^2(1-t)P_2+t^3P_3) , t \in [0,1]$$
I have a circle ("half-bottom-circle") defined as:
$(a, b)$ its center, $R$ its radius, and parametric form :
$$\left(u+a\ ,\ -\sqrt{R^{2}-u^{2}}+b\right), u \in [-R,R]$$
I would like to define $y_2$ (y-coordinate of $P_2$), so that when I move $y_1$, the circle and the Bezier are ALWAYS tangent.
For them to be tangent, 2 conditions are necessary:
1- The slopes of the tangents (derivatives) at the point of tangency are equal :
$$\frac{3\left(1-t\right)^{2}\left(y_{1}-y_{0}\right)+6\left(1-t\right)t\left(y_{2}-y_{1}\right)+3t^{2}\left(y_{3}-y_{2}\right)}{3\left(1-t\right)^{2}\left(x_{1}-x_{0}\right)+6\left(1-t\right)t\left(x_{2}-x_{1}\right)+3t^{2}\left(x_{3}-x_{2}\right)}=\frac{u}{\sqrt{R^{2}-u^{2}}}$$
2- The "y" coordinates at the point of tangency are equal :
$$\left(1-t\right)^{3}y_{0}+3\left(1-t\right)^{2}ty_{1}+3\left(1-t\right)t^{2}y_{2}+t^{3}y_{3}=-\sqrt{R^{2}-u^{2}}+b$$
Now I have two unknowns "$t$" and "$u$", and I am looking for $y_2$.
Algebraically I think it's going to be complicated. I am willing to use Newton-Raphson, but I don't know how to move forward. A little help would be welcome. Thank's.
See my graph
Graph
 A: Let us plug the parametric equation of the Bezier into the implicit equation of the circle:
$$\left(\sum_{k=0}^3 x_kB_k(t)-a\right)^2+\left(\sum_{k=0}^3 y_kB_k(t)-b\right)^2=r^2$$ where the $B_k$'s denote the Bernstein polynomials.
We express that the curve is tangent, or that the above equation has a double root in $t$:
$$\sum_{k=0}^3 x_kB'_k(t)\left(\sum_{k=0}^3 x_kB_k(t)-a\right)+\sum_{k=0}^3 y_kB'_k(t)\left(\sum_{k=0}^3 y_kB_k(t)-b\right)=0.$$
This forms a system of two equations in two unknowns, namely $t$ and $y_2$.
If you expand, you see that the two equations are quadratic in $y_2$. Then writing the condition for two quadratic equations to share a root, which is quartic in the coefficients, you can eliminate $y_2$.
In the end, you will obtain a monstrous polynomial in $t$ that could be of a degree up to $60$ (needs to be checked). This is a clear indication that your problem is arduous and must be solved numerically.

In a more compact form, the equations are
$$(Y(t)+B_2(t)y_2)^2+X^2(t)-r^2=0$$
$$B'_2(t)y_2(Y(t)+B_2(t)y_2)-X'(t)X(t)=0$$ where $X,Y$ denote cubic polynomials.
