# How to find an ellipse , given 2 passing points and the tangents at them?

Please answer to a question , how to find an ellipse which passes the 2 given points and has the given tangents at them. And one related question is that the given condition can decide just one ellipse which satisfies it?

Edit : May be , I can say the first answer (by Mr. André Nicolas) is for the general case. Is there no special case where only a finite set of ellipses satisfies the condition?

Edit : According to the answers and comments , I can compute an arbitrary chosen ellipse for my condition (using the method by Mr.Patrick Da Silva). But there are possibly many others which satisfy my conditions. Am I right?

• There is only one, when your $2$ points are in generic position : check my answer. Commented Feb 16, 2012 at 6:24
• To rephrase André's answer: five conditions are needed to uniquely determine a conic. Thus far you have provided only four (two points and two tangents). Commented Feb 16, 2012 at 6:31
• Then perhaps the center is the missing condition! =P Commented Feb 16, 2012 at 7:22
• This question generated a lot of other questions : I am happy you posted it. Commented Feb 16, 2012 at 7:36
• @J.M. Could you name the fifth property I shuld provide? I can not find it in the answer by Mr.Andre. Commented Feb 16, 2012 at 13:36

Certainly such an ellipse is not uniquely determined. For example, there are lots of ellipses with tangent lines $y=1$ at $(0,1)$ and $y=-1$ at $(0,-1)$: any ellipse $a^2x^2+y^2=1$.

I have not checked that an ellipse with the desired properties always exists. But by a suitable projective transformation we can make the two points nearest neighbours on a pair of parallel lines. After the projection, there is a circle with the desired property, as well as infinitely many non-circular ellipses, and another infinity of hyperbolas. Transform back. It follows that there are infinitely many conics with the desired property.

• If you assume it's an ellipse you're looking for and that the 2 points are in a generic position you're fine. I'm writing an answer at the moment Commented Feb 16, 2012 at 6:03
• @Pat sure, but OP should have specified if the axes of his/her ellipse are parallel to the coordinate axes to begin with... Commented Feb 16, 2012 at 6:29
• Well in that case we should specify it for him, shall we? =) Commented Feb 16, 2012 at 6:35

Here is a complete characterization of all possible ellipses that satisfy the given criteria.

Case 1: The two tangents through the specified points $P$ and $Q$ intersect at a point $O$ distinct from $P$ and $Q$. Then there is an affine transformation mapping $O$, $P$, and $Q$ to $(0,0)$, $(1,0)$, and $(0,1)$ respectively. Under this transformation, any ellipse satisfying the original criteria is mapped to an ellipse passing through $(1,0)$ and $(0,1)$ and tangent to the coordinate axes at those points. All such ellipses are of the form $(x-1)^2+(y-1)^2+2axy = 1$ with $-1 < a < 1$.

Here are some figures from my answer to a duplicate question that I had not realized was a duplicate. The ellipses are shown for $a=\frac12,0,-\frac12$.

Case 2: The two tangents are parallel and neither passes through both points. Then there is an affine transformation mapping $P$ and $Q$ to $(-1,0)$ and $(1,0)$, and the tangents to lines parallel to the $x$-axis. Now there is an infinite family of ellipses given by André Nicolas which satisfy these conditions, namely $ax^2 + y^2 = 1$ with $a > 0$.

Update: See these two previous posts for a way to choose the best ellipse from this one-dimensional family of ellipses, where by "best" we mean the one with the least eccentricity:

• After the affine transform, will tangents remain tangents? Commented Feb 16, 2012 at 9:21
• @Aryabhata: Yes, of course! Tangency is preserved under any transformation whose Jacobian is nonsingular.
– user856
Commented Feb 16, 2012 at 9:57
• The only thing about Jacobian I remember is the plumber joke! :-) Anyway, tangents are preserved for ellipses, as the number of points of intersection does not change. +1. Commented Feb 16, 2012 at 10:32
• A -1 is missing in the formula for Case 1. It should be $(x-1)^2 + (y-1)^2 + a x y - 1 = 0$. Commented Jan 14, 2015 at 7:44
• @Valentas: And in the formula for Case 2 too! Thanks, fixed.
– user856
Commented Jan 14, 2015 at 7:55

It's easier than you think.

You can do it to be tangent to any two lines like for example in this picture $AB$ and $BC$:

Take a point like $D$ (in the picture) then reflect it on the lines $AB$ and $BC$ giving u $D$ and $D'_{1}$ (in the pic) then draw the perpendicular bisector of the line $D'D'_{1}$ (which because in triangle $DD'D'_{1}$, $CB$ and $AB$ are perpendicular bisectors and they pass through $B$, the third perpendicular bisector passes through $B$ too).

Now any point on this line can be used, like $E$. Now draw $ED'$ and $ED_{1}'$ til they intersect to the lines $BC$ and $AB$ respectively at points $P$ and $F$ (sorry i didn’t write the $P$ one) then your ellipses focal points are $E$ and $D$ and the two tangent points are $P$ and $F$.

see..... easy!!!!

And you can prove this (in the second pic):

A given line $AB$ and two given points $C$ and $D$. If you draw an ellipse with the two focal points $C$ and $D$ to be tangent to the line $AB$ at, for example, $E$, $E$ would be the point that $CE+DE$ is minimum value.

So how to find this point?

Answer: Reflect the point $D$ on the line and name it $D'$ then the value $CE+DE=CE+D'E$ and its minimum when the three points $C$ and $E$ and $D'$ are collinear (the nearest distance between two points is the straight line).

So why its tangent?

Because if that is not the minimum value for example the point $E'$ then there exists a second point like $E''$ that $CE'+DE'=CE''+DE''$ (because the amount increases continuously if u move the minimum point to either right or left so for every point in the right there exists one on the left) then it is obvious that the ellipse would intersect the line at two points $E'$ and $E''$. Then its not tangent but for the minimum value its only one point.

• Hi, aria, and welcome to Math.SE. You've picked an interesting Question to start with, but notice that it was asked two years ago. Therefore putting your email into the text of the Answer may not have the result you want. You might be better off registering as a Community member and putting contact information into your profile, but it's entirely up to you to decide. Regards! Commented Mar 17, 2014 at 2:31

There are infinitely many ellipses, even assuming that the two tangent lines intersect.

This follows from the very nice property of an ellipse:

If line $t$ is a tangent to an ellipse at point $P$, and if the focii of the ellipse are $A$ and $B$, then the ray $\overrightarrow{BP}$ reflected on $t$ passes through $A$.

Basically, if you shoot a laser from $B$ to any point on the ellipse, and the ellipse is a perfect mirror, then the reflected ray will pass through $A$!

This can be proven using the physics principle: light takes the route which takes the shortest time. Using the fact that locus of an ellipse is $PA + PB =$ constant, if light from $B$ reflected on the ellipse has to take the shortest time, it can be shown that it has to pass through $A$.

This gives us a way of generating multiple ellipses.

Suppose the given points are $P$ and $Q$ and the tangents ($p$ and $q$ respectively) intersect at $O$, also assume that $\angle{POQ}$ is not acute.

The two tangents divide the plane into four regions. Consider the region $R$ which contains both $P$ and $Q$ on its border.

Now reflect $P$ on the line $q$ at point $Q$. This line intersects $R$ and we get a half-line $S_P$. Similarly reflect $Q$ on the line $p$ at $P$, and we get half-line $S_Q$.

Now given a point $B_i$ (candidate for a focus), we pick a corresponding point $A_i$ (candidate for the other focus) as follows (based on the above reflection property):

Shoot lasers from $B_i$ to $P$ and $Q$ (assuming lines $p$ and $q$ are mirrors) and if they intersect, we pick the point of intersection to be $A_i$.

If it turns out that $PB_i + PA_i = QB_i + QA_i$, then we have our ellipse.

Now given a point $B_1$ on $S_Q$ the corresponding $A_1$ we get is the point $Q$ itself.

We have that $B_1Q + A_1Q \lt B_1P + A_1P$

For a point $B_2$ on $S_P$, the corresponding $A_2$ we get is the point $P$ itself.

We have that $B_2Q + A_2Q \gt B_2P + A_2P$

Now if we pick $B_1$ and $B_2$ sufficiently far from $P$ and $Q$, as we move from $B_1$ to $B_2$, along the segment $B_1 B_2$, there will be a point $B_3$ for which $B_3Q + A_3Q = B_3P + A_3P$ (by continuity arguments) and giving us an ellipse we need.

Now we can pick multiple lines parallel to $B_1B_2$ and use that to get multiple ellipses (at most two parallel lines can give the same ellipse).

If $\angle{POQ}$ is acute, we can pick $B_1$ and $B_2$ on $p$ and $q$ itself, with $P$ lying between $O$ and $B_1$ and $Q$ lying between $O$ and $B_2$ and $B_1$, $B_2$ being sufficiently far from $O$.

• How is this relevant? The focii of the ellipse is not given... I don't understand your answer. We are given two slopes, not one. Commented Feb 16, 2012 at 7:18
• @PatrickDaSilva: I am claiming, given a random point $B$, you can find a corresponding point $A$ (or $A_B$ for more clarity), such that there is an ellipse with focii $B$,$A$ which is tangent to the two given lines at the two given points. Commented Feb 16, 2012 at 7:21
• I really want to like your beautiful answer, but I can't get it to work. Take an equilateral triangle $PQR$. Let the specified points be $P$ with tangent along $PQ$, and the midpoint of $QR$ with tangent along $QR$. Pick point $B$ randomly at the center of the triangle. The reflected lasers meet at $P$, and I'm fairly sure you can't have an ellipse with foci at $P$ and $B$ that passes through both $P$ and the midpoint of $QR$.
– user856
Commented Feb 16, 2012 at 7:27
• If you do some drawings, you may even notice that the intersections of the two reflections of $BP_1$ and $BP_2$ be not even inside the convex hull of $B$ and your two lines, which makes total non-sense for your algorithm. Commented Feb 16, 2012 at 7:34
• @PatrickDaSilva: Rahul and you have raised some valid concerns. Commented Feb 16, 2012 at 7:51

EDIT: As Rahul's comment points out, I assumed implicitly that the ellipse was centered at the origin. This is important ; for everything to work out well here, you need the two points to be linearly independent vectors, the center must be assumed at the origin and obviously the tangent lines must not got through the origin. Since there is no ellipse over which two linearly independent points have parallel tangent lines, we must also assume that the tangent lines are intersecting somewhere else than at infinity.

Actually what you need is the normal vectors. An ellipse is completed characterized by $3$ coefficients, namely the $a$, $b$ and $c$ that define $$ax^2 + bxy + cy^2 = 1.$$ The gradient of the function $f(x) = ax^2 + bxy + cy^2$ gives you the normal vectors to the ellipse by computing $$\nabla f(x) = \begin{bmatrix} 2ax + by \\ bx + 2cy \end{bmatrix} = \begin{bmatrix} 2a & b \\ b & 2c \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}.$$ You know the normal vectors at two linearly independent points in the plane (this is very important, otherwise your condition can represent more than one ellipse). Therefore, you can compute them at $X_1 = (x_1, y_1)$ and at $X_2 = (x_2, y_2)$ to get $(\alpha_1, \beta_1)$ and $(\alpha_2, \beta_2)$ the normal vectors at $X_1$ and $X_2$. To make sure your normal vector points "outside of the ellipse", project it on its underlying point. In other words, if $(\alpha_1, \beta_1)$ is the normal vector at $(x_1, y_1)$, then compute $x_1 \alpha_1 + x_2 \beta_2$. This should be non-zero ; if it's positive, the sign is good for an ellipse. If it's negative, it's wrong ; change it. All this gives you the linear system $$\begin{bmatrix} 2a & b \\ b & 2c \end{bmatrix} \begin{bmatrix} x_1 & x_2 \\ y_1 & y_2 \end{bmatrix} = \begin{bmatrix} \alpha_1 & \alpha_2 \\ \beta_1 & \beta_2 \end{bmatrix}.$$ If you invert the matrix with the $x$'s and $y$'s (which I assumed was possible), you get the $a$'s, $b$'s and $c$'s.

Hope that helps,

• Okay I'm done =) Everything should be fine now. Commented Feb 16, 2012 at 6:33
• Two problems: 1. You assume that the ellipse is centered at the origin. 2. An ellipse being a geometric figure, its normals do not come equipped with a magnitude. That is, your "normal vectors" $(\alpha,\beta)$ do not depend solely on the ellipse itself but also on the scaling of the equation $f(x) = \text{const}$.
– user856
Commented Feb 16, 2012 at 7:09
• @Rahul : 1 needs to be noticed, but I have worked a lot with ellipses and I always assumed them centered at the origin... if OP wants unicity then he also needs to specify the center of his ellipse, obviously. 2 is taken care of though : I assumed $f(x) = 1$. Therefore the ellipse is uniquely characterized by $f$, since the constant is not a variable. Commented Feb 16, 2012 at 7:17
• @Rahul : I think I noticed what you're worried about ; maybe your frame of mind tells you that you can generate ellipses given a positive definite quadratic and fixing it equal to a positive constant. What I'm saying is that the roots of this equation $f(x) = d$ are the same as the ones of the equation $f(x)/d = 1$ and then I'm finding the coefficients of $f(x)/d$. If you want your cute constant on the right of the equation then put it there if you wish to. =) Commented Feb 16, 2012 at 7:25
• I guess I'm not getting my point across. How would you use your method to find an ellipse passing through $(1,0)$ with a vertical tangent, and $(0,1)$ with a tangent parallel to the line $x=y$?
– user856
Commented Feb 16, 2012 at 11:28

A conic curve (as an ellipse) is in general given by 5 points. If 2 of these points get very close together, we can see that this condition in the limit is equivalent to give a point and the tangent at that point. So there are in general infinite solutions (2 points and 2 tangents are "equivalent" to 4 points and then we have another point left)

David Vergés Barcelona, Catalonia

Added: Projective transformations are powerful tools to treat this type of problems.

Suppose the two given points are $$P_0$$ and $$P_1$$, and let $$P_a$$ be the intersection of the tangent lines at $$P_0$$ and $$P_1$$. Then, for any weight $$w$$, the rational quadratic Bezier curve $$P(t) = \frac{(1-t)^2 P_0 + 2wt(1-t) P_a + t^2 P_1} {(1-t)^2 + 2wt(1-t) + t^2}$$ has the shape that you want, and it is a conic section curve (ellipse, parabola, or hyperbola). So, first of all, this shows that there are an infinite number of conics that satisfy your conditions.

The value of $$w$$ determines the type of conic section curve: if $$0, you get an ellipse, $$w=1$$ gives you a parabola, and $$w>1$$ gives a hyperbola. This shows that there are an infinite number of ellipses that satisfy your conditions (and an infinite number of hyperbolas, too).

One reasonable way to choose the "best" solution is to minimize the eccentricity of the conic. They show you how to do this in the following paper:

Least eccentric ellipses for geometric Hermite interpolation
John C. Femiani, Chia-Yuan Chuang, Anshuman Razdan
Computer Aided Geometric Design 29 (2012) 141–149

They show that if $$a$$, $$b$$, $$c$$ denote the lengths of the triangle sides $$P_0P_a$$, $$P_a P_1$$, $$P_0 P_1$$, then minimum eccentricity is achieved when $$w = \frac{c}{ \sqrt{2(a^2+b^2)} }$$ The expression on the right-hand side is always $$<1$$, which shows that the minimum-eccentricity solution is always an ellipse.

If you want an implicit equation of the conic in the form $$f(x,y)=0$$, you have to eliminate $$t$$ from the first equation above. Then you can use standard eigenstuff techniques to get the center, rotation, and semi-axis lengths of the ellipse.

• I found your rational quadratic Bezier curve to be very helpful in completing a problem I'm working on. Just for my own edification, however, I wonder if you can point me in the direction that will give me, for example, the completed ellipse to overlay on the Bezier curve. I'd like to get an idea of the centroid and semi-major/minor axes. Commented Apr 25, 2020 at 0:21
• What you're asking about is called "implicitization" -- we're deriving the implicit equation of the conic curve from its parametric form. If you google this term, you'll find plenty of references. The classic paper on the subject was written by Eugene Lee in 1987. Commented Apr 27, 2020 at 4:11
• Try this paper and the references they cite: sciencedirect.com/science/article/pii/S0167839610000385 Commented Apr 27, 2020 at 4:16
• Also: "Characteristics of conic segments in Bezier form" by Javier Sánchez-Reyes (Proceedings of the IMProVe 2011, pp. 231-4). Commented Apr 27, 2020 at 5:20
• Thanks for your replies. I was somewhat surprised because I thought you had disengaged. Glad to see that you're back. Perhaps you should update your profile? Commented Apr 27, 2020 at 16:43

I think you'll find that center of the ellipse lies on a line passing through tangent intersection and the midpoint of the secant between those points... Incidentally, it's a property I found myself when faced with this problem, and only later found it corroborated in a book (Matematische Formelsammlung, from 1950-and-something). That will give you 5th equation needed to solve for $$x_0 , y_0 , a , b, and \ \phi$$.