# Two tangent points of two lines from (0,0) to an ellipse

How do I find the two tangent points of two lines from (0,0) to an ellipse?

We have 2 equations, a general ellipse and it differentiated:
1: A*x*x+B*x*y+C*y*y+D*x+E*y+F=0 is an ellipse if B*B-4*A*C<0.
Differentiating, 2: 2*A*x+B*x*dy/dx+B*y+2*C*y*dy/dx+D+E*dy/dx=0.

If F<0, ellipse not on (0,0), line from (0,0) tangent to ellipse is:
3: y=dy/dx*x where dy/dx is that of the ellipse. So 3:dy/dx=y/x.

Rearranging equation 2:
2: dy/dx=-(2*A*x+B*y+D)/(2*C*y+B*x+E).

Combining equation 2 with equation 3:
4: 2*(A*x*x+B*x*y+C*y*y)+D*x+E*y=0.

But we haven't satisfied the ellipse equation 1 yet so
Solving equations 1 and 4 together,
(D*x+E*y)/2+F=0, but that's not a tangent-point solution.

How do I get the two solutions of equations 1 and 4?
Did I make a mistake, or am I doing it wrong?

HallsofIvy
Homework Helper
There is nothing wrong and you have done extremely well! Now, solve that equation for, say, y and put it into your original equation for the ellipse. That will give you a quadratic equation for x, giving the x coordinate of the two points of tangency.

Solving equations 1 and 4 together,
5: (D*x+E*y)/2+F=0, a line not a tangent-point solution.
Rearranging by writing y as a function of x,
5: y=-(x*D/E+2*F/E) and y*y=((D*D/(E*E))*x*x+2*D*F/(E*E)*x+4*F*F/(E*E)

Substituting into the ellipse equation 1,
6: A*x*x-B*x*(x*D/E+2*F/E)+C*(((D*D/(E*E))*x*x+2*D*F/(E*E)*x+4*F*F/(E*E))+D*x-E*(x*D/E+2*F/E)+F=0
Collecting terms for a quadratic to solve using x=(-b+-sqrt(b*b-4*a*c))/(2*a),
6: (A-B*D/E+C*D*D/(E*E))x*x+2*(C*D*F/(E*E)-B*F/E)*x+(4*F*F/E-F)=0

I Used the quadratic formula and got two points that I will
check when I plot and give thus verified code then.

I also need ellipse tangency points of the two tangent circles about (0,0),
but will also have to work on that later, and that is more difficult.
Anyone have the solutions.