The goal is to programmatically draw a path between the 2 points that follows a conic curve if one exists. Approximations and iterative methods are acceptable.
Let's start with a simple, parametric ellipse.
$$ \bar{x}(t) = \begin{bmatrix}x(t)\\y(t)\end{bmatrix} = \begin{bmatrix}a\cos{t}\\b\sin{t}\end{bmatrix} $$
Next, apply some rotation $\theta$ and translation $(c_x,c_y)$.
$$ \begin{bmatrix} \cos{\theta} & -\sin{\theta}\\ \sin{\theta}\ & \cos{\theta} \end{bmatrix} \begin{bmatrix} a\cos{t}\\b\sin{t} \end{bmatrix} + \begin{bmatrix} c_x\\c_y \end{bmatrix} = \begin{bmatrix} a\cos{t}\cos{\theta}-b\sin{t}\sin{\theta}+c_x\\ a\cos{t}\sin{\theta}+b\sin{t}\cos{\theta}+c_y \end{bmatrix} $$
Now we have a general, parametric equation of an ellipse. Let's try out some product-to-sum identities.
$$ \begin{bmatrix} a\frac{\cos(t-\theta)+\cos(t+\theta)}{2}-b\frac{\cos(t-\theta)-\cos(t+\theta)}{2}+c_x\\ a\frac{\sin(t+\theta)-\sin(t-\theta)}{2}+b\frac{\sin(t+\theta)+\sin(t-\theta)}{2}+c_y \end{bmatrix} = \begin{bmatrix} \frac{a-b}{2}\cos(t-\theta)+\frac{a+b}{2}\cos(t+\theta)+c_x\\ \frac{a+b}{2}\sin(t+\theta)-\frac{a-b}{2}\sin(t-\theta)+c_y \end{bmatrix} $$
Let $C=\frac{a-b}{2}$ and $D=\frac{a+b}{2}$.
$$ \begin{bmatrix} x(t)\\ y(t) \end{bmatrix} = \begin{bmatrix} C\cos(t-\theta)+D\cos(t+\theta)+c_x\\ D\sin(t+\theta)-C\sin(t-\theta)+c_y \end{bmatrix} $$
Since tangents are available, taking a derivative makes sense to me.
$$ \begin{bmatrix} x'(t)\\ y'(t) \end{bmatrix} = \begin{bmatrix} -C\sin(t-\theta)-D\sin(t+\theta)\\ D\cos(t+\theta)-C\cos(t-\theta) \end{bmatrix} $$
Let's set up the constraints. The points are $(x_1,y_1)$ and $(x_2,y_2)$ and their respective tangents are $(x'_1,y'_1)$ and $(x'_2,y'_2)$. Let $t_1$ and $t_2$ correspond to the points. For $i=1,2$:
$$ x(t_i) = x_i \quad y(t_i) = y_i \quad x'(t_i) = x'_i \quad y'(t_i) = y'_i $$
Rearranging the equations.
$$ x(t_i)+y'(t_i)=x_i+y'_i=2D\cos(t_i+\theta)+c_x\\ x(t_i)-y'(t_i)=x_i-y'_i=2C\cos(t_i-\theta)+c_x\\ y(t_i)+x'(t_i)=y_i+x'_i=-2C\sin(t_i-\theta)+c_y\\ y(t_i)-x'(t_i)=y_i-x'_i=2D\sin(t_i+\theta)+c_y\\ $$
Applying Pythagorean identity.
$$ (x_i+y'_i-c_x)^2+(y_i-x'_i-c_y)^2=4D^2\\ (x_i-y'_i-c_x)^2+(y_i+x'_i-c_y)^2=4C^2 $$
There are four free variables $(c_x,c_y,C,D)$ and four quadratic equations.
Let $$ k_{i,1}=x_i+y'_i \quad k_{i,2}=y_i-x'_i \quad k_{i,3}=x_i-y'_i \quad k_{i,4}=y_i+x'_i $$
$$ (k_{i,1}-c_x)^2+(k_{i,2}-c_y)^2=4D^2\\ (k_{i,3}-c_x)^2+(k_{i,4}-c_y)^2=4C^2 $$
These aren't any quadratic equations. These are equations for circles. There are four circles. Two centered on $(k_{1,3},k_{1,4})$ and $(k_{2,3},k_{2,4})$ with radius $2C$. And another two centered on $(k_{1,1},k_{1,2})$ and $(k_{2,1},k_{2,2})$ with radius $2D$.
$$ (k_{1,1}-c_x)^2+(k_{1,2}-c_y)^2=4D^2=(k_{2,1}-c_x)^2+(k_{2,2}-c_y)^2\\ (k_{1,3}-c_x)^2+(k_{1,4}-c_y)^2=4C^2=(k_{2,3}-c_x)^2+(k_{2,4}-c_y)^2 $$
Let's move everything to the left hand side and do some factoring.
$$ (k_{1,1}-c_x)^2-(k_{2,1}-c_x)^2+(k_{1,2}-c_y)^2-(k_{2,2}-c_y)^2=0\\ (2c_x-(k_{2,1}+k_{1,1}))(k_{2,1}-k_{1,1})+(2c_y-(k_{2,2}+k_{1,2}))(k_{2,2}-k_{1,2})=0\\ 2(k_{2,1}-k_{1,1})c_x+2(k_{2,2}-k_{1,2})c_y+(k_{1,1}^2+k_{1,2}^2)-(k_{2,1}^2+k_{2,2}^2)=0 $$
Similarly,
$$ 2(k_{2,3}-k_{1,3})c_x+2(k_{2,4}-k_{1,4})c_y+(k_{1,3}^2+k_{1,4}^2)-(k_{2,3}^2+k_{2,4}^2)=0 $$
$$ \begin{bmatrix} 2(k_{2,1}-k_{1,1}) & 2(k_{2,2}-k_{1,2})\\ 2(k_{2,3}-k_{1,3}) & 2(k_{2,4}-k_{1,4}) \end{bmatrix} \begin{bmatrix} c_x\\ c_y \end{bmatrix} + \begin{bmatrix} (k_{1,1}^2+k_{1,2}^2)-(k_{2,1}^2+k_{2,2}^2)\\ (k_{1,3}^2+k_{1,4}^2)-(k_{2,3}^2+k_{2,4}^2) \end{bmatrix} =0 $$
To be continued...
