Check if a circle is within an ellipse I have an ellipse centered at $(h,k)$, with semi-major axis $r_x$, semi-minor axis $r_y$, both aligned with the Cartesian plane.
How do I determine if a circle with center $(x,y)$ and radius $r$ is within the area bounded by the ellipse
 A: Idea: doing a translation we can suppose than the circle is centered at $(0,0)$. Parametrize the equation of the ellipse:
$$x(t) = h + r_x\cos t,$$
$$y(t) = k + r_y\sin t.$$
And find the maximum and minimum of $t\mapsto x(t)^2 + y(t)^2$.
A: Solve for $x$ or $y$ from
$$\frac{(x-h)^2}{r_x^2}+\frac{(y-k)^2}{r_y^2}=1$$
and
$$\frac{(x-h)^2}{r^2}+\frac{(y-k)^2}{r^2}=1 . $$
If the point of intersection is complex due to quantity under radical sign (discriminant) being negative, then the circle is inside the ellipse.
If it is zero, the circle touches the ellipse and if posive there is intersection between them at 2 or 4 points.
A: An ellipse and a circle are both on 2d space.
the ellipse is centered at $A$ and the circle is centered at $B$
first find the vector between them $B-A$ call it $D$
Make a variable $N$ that is the normal of $B-A$
We know that the strait line from the circle to the ellipse is where the circle is closest subtract the Normal times the radius from $D$
Solve for the intersection of an ellipse.
In code it would look like this:
var dx = circleX-ellipseX;
var dy = circleY-ellipseY;
var d = 1/sqrt(dx*dx + dy*dy);
var nx = dx*d;
var ny = dy*d;
dx -= nx*circleRadius;
dy -= ny*circleRadius;
//Ry is ellipse height
//Rx is ellipse width
if(Ry*Ry*dx*dx + Rx*Rx*dy*dy < Rx*Rx*Ry*Ry){
    score += 10;
    food[0] = width+15;
}

