# how to find the tangent line from a point to an ellipse

Basically, I would like to calculate the purple line, (in the image).

The requirements are that it starts in the lower left point (25,820 ) or in the lower right point (symmetry). And it has to touch the ellipse (like in the image). (It is not allowed to cross|enter the ellipse).

[ At the end, I've the know the point where the two purple line crosses each other, but that isn't a problem. But therefore I've to know both tangent points] I think that this should be enough. Thus can someone help me with calculating the tangent point?

• what is the equation of your Ellipse? – Dr. Sonnhard Graubner Sep 17 '17 at 13:15
• @Dr.SonnhardGraubner All the necessary information is in the diagram. – Théophile Sep 17 '17 at 13:35
• @Dr.SonnhardGraubner : x³ / 380² + y² / 185² = 1 ---> can you view the image? – Dieter Verbeemen Sep 17 '17 at 15:27

You can find tangency points with a simple geometric construction. Let $P$ be a point external to the ellipse, and $F$, $F'$ be its foci.

1. Draw a circle centered at $F'$, with radius $2a$, equal to the major axis of the ellipse.

2. Draw a circle centered at $P$, with radius $PF$; this circle will meet the other circle at two points $M$ ad $M'$.

3. Join $F'M$ and $F'M'$: these segments cut the ellipse at the tangency points $Q$ and $Q'$.

In other words: tangents $PQ$ and $PQ'$ are the perpendicular bisectors of segments $MF$ and $M'F$. • That's a nice construction; I wasn't aware of it. In your last step, I think you mean $F'$, not $S'$ (in both instances). – Théophile Sep 17 '17 at 16:24
• @Théophile Of course, thank you: corrected now. – Intelligenti pauca Sep 17 '17 at 16:36

Let's look at an easier problem first: suppose that instead of an ellipse, you have a circle of radius $1$ centred at the origin. Let your known point (to the right of and below the circle) be $(r,s)$, and consider the line through $(r,s)$ and tangent to the circle at $(\cos\theta, \sin\theta)$ for some $\theta$. (There are two such tangent lines; we're interested in only one of them.)

You can check that the tangent line will be $$x\cos\theta + y\sin\theta = 1.$$

Since the line passes through $(r,s)$, substitute those points to get $$r\cos\theta + s\sin\theta = 1;$$ now we must solve for $\theta$. We can combine the two sinusoid functions to get $$\sqrt{r^2+s^2}\cos\left(\theta+\tan^{-1}\left(\frac{-s}r\right)\right)=1,$$ and solving for $\theta$ we get $$\theta = \cos^{-1}\left(\frac1{\sqrt{r^2+s^2}}\right) - \tan^{-1}\left(\frac{-s}r\right).$$

Finally, all that remains is to transform your problem into the one described here. First translate so that the ellipse is centred at the origin, then scale the axes to transform the ellipse into a circle of radius $1$. Solve for $\theta$ as described above, then reverse the scaling and translation.

Since an ellipse is just a scaled circle, consider the construction with the circle at the origin first and find the coordinates of the tangent point:

\begin{align} |OB|&=\sqrt{(r+d)^2+c^2} .\\ t&=\sqrt{OB^2-r^2} ,\\ \alpha&=\arctan\tfrac{r}{t} ,\\ \beta&=\arctan\tfrac{r+d}c ,\\ T_x=|CT_1|&= c-t\,\cos(\alpha+\beta) ,\\ T_y=|TT_1|-r-d &= t\,\sin(\alpha+\beta) -r-d ,\\ \cos(\alpha+\beta) &= \frac{tc-r^2-rd}{\sqrt{t^2+r^2}\sqrt{c^2+(r+d)^2}} ,\\ \sin(\alpha+\beta) &= \frac{rc+tr+td}{\sqrt{t^2+r^2}\sqrt{c^2+(r+d)^2}} . \end{align}

Given this, can you find the corresponding tangential point on the ellipse?

• don't know :-) mistakes are easily made (i don't know it on top of my head) – Dieter Verbeemen Sep 17 '17 at 17:23
• @Derp Derpington: Just look at the ellipse. What we need to do to transform it to the circle at the origin? Shift all coordinates to put its center at (0,0), then scale $x$ coordinate by $b/a$, set values for $r,d,c$, follow the equations for the circle and make the inverse transform. – g.kov Sep 17 '17 at 17:41
• @DerpDerpington Remember that you also have to transform the points through which you’re drawing the tangents. – amd Sep 18 '17 at 18:42
• @DerpDerpington: Yes, as amd already noticed, you need to transform all coordinates, not just the ellipse axes, and than transform them back. – g.kov Sep 18 '17 at 18:47
• @DerpDerpington: That is, especially the value of $c$ need to be transformed. – g.kov Sep 18 '17 at 18:50

The other answers give you several ways to compute the tangent lines through a point. I’ll instead describe a simple way to solve the original problem that you say led to this question. You don’t really need to find the purple lines or their points of tangency explicitly in order to compute their intersection point.

By symmetry, the intersection point lies somewhere on the ellipse’s minor axis. Keep in mind that there are two tangent lines through every point external to the ellipse, so you’ll have to select the correct ones in this computation. For simplicity, first translate the ellipse to the origin. Its equation is then the one that you gave in a comment to the question. The two points through which we’re drawing the tangents are transformed into $(\pm600,295)$. Now, switch to homogeneous coordinates. The lines through these two points and an arbitrary point $(0,y)$ on the $y$-axis are $$\mathbf l=[\pm600:295:1]\times[0:y:1]=[295-y:\pm600:\mp600y].$$ The matrix of the ellipse is $C=\operatorname{diag}(380^{-2},185^{-2},-1)$ and the lines are tangent to the ellipse when $$\mathbf l^TC^{-1}\mathbf l=0.$$ Plugging either line into this equation produces a quadratic equation in $y$: $$380^2\cdot(295-y)^2+185^2\cdot600-(600y)^2=0$$ with solutions $y\approx195.449$ and $y\approx-590.606$. The two solutions reflect the facts that there are two tangent lines through each point and that two of their pairwise intersections lie on the $y$-axis. It looks like you’re interested in the point with the lesser $y$-coordinate, and translating that back to the original coordinate system gives something like $(625,-65.606)$ as the point of intersection of the two tangent lines.

More generally, if you have the ellipse ${x^2\over a^2}+{y^2\over b^2}=1$ and points $(\pm x_p,y_p)$, following the above procedure results in the quadratic equation $$(a^2-x_p^2)y^2-2a^2y_py+b^2x_p^2+a^2y_p^2=0$$ with solutions $$y={a^2y_p\pm x_p\sqrt{b^2x_p^2+a^2y_p^2-a^2b^2}\over a^2-x_p^2},$$ provided $x_p\ne a$. In the latter case, two of the tangent lines will be parallel and the equation reduces to $$-2a^2y_py+a^2(y_p^2+b^2)=0$$ which I’m sure you can solve for yourself.

Of course, once you know $y$, you also have the answer to your more specific question: substituting its value into the expression for $\mathbf l$ gives you the two tangents, and the points of tangency are their polar points $C^{-1}\mathbf l$.

The tangent points are at about $58$ units north from the horizontal axis of the ellipse and about $239$ unit East from the bottom left point. In your coordinates should be $(264,467)$ the left one and $(986,467)$ the right one.

The intersection point of the tangent should be approximately in your coordinates at $(625,-66)$

Hope this is useful

• @amd I made calculations and then converted in the system of the OP which is completely different. Have you noticed that the points on the bottom have a larger $y$ than the top points? I guess he/she is working in pixels in some graphic oriented language. I recognized this because I did something similar in Visual Basic – Raffaele Sep 18 '17 at 18:43
• @amd Thank you! Really I messed up inverting coordinates and other stupid things :) – Raffaele Sep 18 '17 at 19:14
• I think that your answer would be more useful if you explained how you got those values. – amd Sep 19 '17 at 8:52