# How do I know if a given set of points on a convex quadrilateral are valid tangent points for an ellipse fitting inside that quadrilateral?

There is one point designated for each side of the quadrilateral. The ellipse is contained within the quadrilateral.

I am curious about this because when using linear perspective to plot ellipses in my drawings I first make quadrilaterals, then deduce the tangent points, then plot the ellipse. It would be nice to have some way of checking those tangent points to make sure they are valid.

Take for example the image below, given points E,F,G, & H on the convex quadrilateral ABCD I don't see a way to construct an ellipse that is tangent to all those points. Is there a formulaic/algorithmic way of knowing if a given set of points can/cannot construct an ellipse on a given quadrilateral without trial and error (In an app like GeoGebra)?

• This suggests that you only need to solve this problem in the case of a square: math.stackexchange.com/a/3067053/54092 – Lorenzo Najt Sep 11 '20 at 5:54
• Are you suggesting there are only one set of valid tangent points for a given (convex) quadrilateral? – Audus Sep 11 '20 at 5:57
• No, it seems to be the case that there is an interval of such ellipses. I mean the following: Work in the case of a square $S$ and fix a side interval L. My guess, based on playing with this geogebra.org/m/d4k6SjFX , is that for each $x \in L$, there is a unique ellipse tangentially inscribed inside of of $S$ that contains $x$. I think I can prove this existence, but am not sure about uniqueness. – Lorenzo Najt Sep 11 '20 at 6:52
• If you give four tangents, then you can choose at will ONE point on the ellipse, lying inside the convex quadrilateral formed by the tangents (but not at its vertices). In general, five conditions (points or tangents) define a conic section. – Intelligenti pauca Sep 11 '20 at 9:19
• Tangent points you get from a perspective transformation of a circle into a square are automatically the right ones. But the ellipse you get is only a special case among an infinite number of ellipses which can be inscribed into the quadrilateral resulting from the square. – Intelligenti pauca Sep 11 '20 at 9:26

Any convex quadrilateral can be mapped to a square by a suitable perspective transformation, and an ellipse inscribed into the quadrilateral is then mapped to an ellipse inscribed into the square, having then its axes along the diagonals of the square (see figure below).

In this case, lines through tangency points $$P$$ and $$R$$, parallel to sides $$CD$$ and $$BC$$ respectively, intersect diagonal $$AC$$ at the same point $$V$$. Moreover, tangency points $$P$$, $$Q$$ are aligned with the centre $$O$$ of the square, and the same goes for the other two tangency points $$R$$ and $$S$$.

As perspective transformations preserve collinearity of points, these properties of tangency points can be reinterpreted for the case of an ellipse inscribed into a generic convex quadrilateral (see figure below).

Lines $$CD$$, $$AB$$, $$PV$$ are now concurring, and the same happens for lines $$BC$$, $$AD$$, $$RV$$. Points $$POQ$$ are aligned, as well as $$ROS$$. It follows that once we fix a tangency point, the other ones are uniquely determined by these properties.

• Thank you for posting diagrams. I understand the basic concept of projecting the forms to a square to check the properties. – Audus Sep 14 '20 at 1:29

As mentioned in the comments, you can apply a projective transformation and turn the quadrilateral into a square. This works because if you hit an ellipse with a projective transformations that keeps it bounded it remains an ellipse. So we deal with that case from now on.

Let the four sides of $$S$$ be denoted $$S_R, S_L,S_T, S_B$$, with subscript standing for right, left, top, bottom. Let's assume that $$S_B$$ is the $$x$$-axis; this will be notationally convenient later.

The question is : given $$p_i \in S_i$$, $$i \in \{R,L,T,S\}$$, is there an inscribed ellipse tangent to the four sides at the $$p_i$$?

An algorithm to decide this equation (and produce the ellipse if it exists) is sketched below. The moral of the story is that it is a linear algebra problem.

An ellipse $$E$$ has a general formula: $$a x^2 + by^2 + c xy + dx + ey + f= 0.$$

If we assume $$f \not = 0$$, we can normalize it to $$1$$. (You can avoid this annoying case analysis with projective coordinates.) Let's assume we are in this case, and I'll leave the other case to you, so the equation is:

$$a x^2 + by^2 + c xy + dx + ey + 1= 0.$$

Note that there are 5 variables here, so we have a five dimensional vector space with coordinates $$(a,b,c,d,e)$$.

Consider the point $$p_i = (x_i, y_i)$$. If $$p_i \in E$$, then $$a x_i^2 + by_i^2 + c x_iy_i + dx_i + ey_i + 1 = 0.$$ The $$x_i, y_i$$ are fixed numbers, so this is a linear equation in the variables $$(a,b,c,d,e)$$.

We get four such equations. The set of solutions to them will be a line(see footnote (*) ), which you can compute with linear algebra.

We now examine the condition that $$E$$ is tangent to the base of the square, namely the $$x$$-axis. The $$x$$-axis is defined by the equation $$y = 0$$, so the equation defining $$E$$ becomes $$q(x) = ax^2 + dx + 1 = 0$$ when we restrict to the $$x$$-axis.

One way to proceed from here is to use the fact that this quadratic is tangent to the $$x$$-axis iff the quadratic $$q$$ has a double root, which happens iff the discriminant vanishes, i.e. $$d^2 - 4a = 0$$. However, this is wasteful, since we have additional information; in particular, we know that $$q(x)$$ must touch tangentially at the particular point $$p_B$$. In particular, we want the derivative of $$q$$ to vanish at $$x_B$$.

So, we get one more condition, namely $$q'(x) = 2a x + b$$ vanishes at $$x_B$$, or $$2ax_B + b = 0$$.

This gives us five equations in general, cutting us down to a single conic, which might be your desired ellipse. To see whether corresponds to your ellipse, you can:

1. Test if it is an ellipse by (symbolically) completing the square.
2. Test each one against the 3 other tangency conditions.
3. You can also make sure that it is on the right side of all 4 lines by checking the ellipse restricted to each of the four sides gives a quadratic with the correct sign in front of the quadratic term.

If the conic passes these tests, it is a solution to your problem. Otherwise, there is no solution with specification the given $$p_i$$.

I think these tests are likely to be redundant. In particular, I think an ellipse tangent to the four intervals must lie inside it, so you can probably eliminate the third condition.

(*) You can prove, I think, that the conditions do not conspire and become linearly dependent for bad choices of points. Fix your $$p_i$$. Then there is conic passing through $$p_L$$ but not $$p_B$$. Also, there is a conic passing through $$p_L$$ and $$p_B$$, but not $$p_R$$. Finally, there is a conic passing through $$p_L, p_B, p_R$$ but not $$p_U$$. I didn't formally verify these statements, just did some doodles with parabolas and circles, so I'd double check this point. I think the same is true regarding imposing the final linear condition that one of these intersections is tangential.

If this is correct, then each time you add one of these conditions you necessarily eliminate some conics, meaning that the dimension of the space drops when you impose the new constraint.

A more algebraic and believable argument would be to explicitly construct equations a sequence of conics achieving each of these intermediate conditions.

Remark I believe the following is true: For each $$x \in S_B$$ there is a unique ellipse tangentially inscribed in $$S$$ that contains $$x$$, provided $$x$$ is not at a corner. So, there is actually an interval of ellipses satisfying you constraints. I'm not sure about this though. I think that via projective duality the above argument would give uniqueness. I convinced myself of existence through a half backed argument about inflating an ellipse passing through $$x$$ and the antipode of $$x$$ around the midpoint of the square, but I'm not sure if it can be easily formalized.

• Thank you for such a thorough answer! – Audus Sep 14 '20 at 1:32