# Check if disk lies within an ellipse

I have an ellipse in normal form centered at the origin and want to check whether a disk with given center point and radius is contained completely in the ellipse without touching it.

If I could compute the shortest distance between a point and the ellipse then I can just check if this distance is larger than the disk radius. How would I calculate this distance and are there other ways to solve this problem?

(Related to this question.)

First, the center $P_0 =(x_0, y_0)$ has to be inside the ellipse $\frac{x^2}{a^2} + \frac{y^2}{b^2} =1$ and this means $$\frac{x_0^2}{a^2} + \frac{y_0^2}{b^2} < 1$$

Now, let's determine the closest point $(P_1 = (x_1, y_1)$ on the ellipse to $(x_0, y_0)$. At such a point the tangent to the ellipse, which is given by the ecuation

$$\frac{x_1 x }{a^2} + \frac{y_1 y }{b^2} =1$$ has to be perpendicular to the segment $P_0 P_1$. Hence, we need to have

$$\frac{x_1(x_1- x_0)}{a^2} + \frac{y_1(y_1- y_0)}{b^2}=0$$

Thus we get the system in the unknowns $(x_1, y_1)$

\begin{eqnarray} \frac{x_1^2}{a^2}& +& \frac{y_1^2}{b^2} =1\\ \frac{x_0 x_1}{a^2} &+& \frac{y_0 y_1}{b^2} =1 \end{eqnarray}

which has two solutions (possibly equal). From them we get the one $P_1$ for which the distance is shortest ( for the other one it will be the longest).

Supposing that the disk's equation is given by:

$$(x-x_0)^2 + (y-y_0)^2 \le r^2 \ \ \ (\star)$$

And that the interior of the ellipse has the equation:

$$\frac{(x-x_1)^2}{a^2} + \frac{(y-y_1)^2}{b^2} < 1 \ \ \ (\star \star)$$

Check whether $(\star) \implies (\star \star)$

Disk equation is given by:

$$(x-h)^2 + (y-k)^2= R^2$$

And ellipse :

$$\frac{(x-H)^2}{a^2} + \frac{(y-K)^2}{b^2}= 1 \ \ \$$

Calculate a value of x or y intersection after eliminating one of them.

To be within the ellipse the quadratic equation should have imaginary roots, discriminant should be $<0$ or zero for contacting ellipse and circle.