I was hoping to write some code to find the intersection of a circle and an ellipse but it's turned out to be more difficult than I expected. Both have shifted centres and are not rotated. I also do not know the polynomial representation of the ellipse, so my question does not match others posted on this site so far, which present the problem as solving a polynomial in two variables ($x$ and $y$).
The Cartesian equations are:
- a circle: $(x - X_c)^2 + (y - Y_c)^2 = r^2$
- an ellipse: $\frac{(x - x_c)^2}{a^2} + \frac{(y - y_c)^2}{b^2} = 1$
The parametric equations ($t \in [0, 2\pi]$) are:
- a circle: $x = X_c + r\frac{1-t^2}{1+t^2}$; $y = Y_c + r\frac{2t}{1+t^2}$
- an ellipse: $x = x_c + a \cdot cos(t)$; $y = y_c + b \cdot sin(t)$
[N.B. I've tried to distinguish the centre of the circle $(X_c, Y_c)$ and the centre of the ellipse $(x_c, y_c)$]
I've seen it suggested that substituting $(x,y)$ from the parametric circle definitions into the Cartesian equation for the ellipse will give a polynomial of degree 4 in terms of $t$ whose real solutions (polynomial roots) give the coordinates of the point(s) of intersection:
$\frac{1}{a^2}(X_c - x_c + r\frac{1-t^2}{1+t^2})^2 + \frac{1}{b^2}(Y_c - y_c + r\frac{2t}{1+t^2})^2$
... however I've been unable to figure out what algebraic rearrangement is needed to get these solutions.
I have also had no hints from trying to provide the formula to rearranging programs like Wolfram Alpha, and cannot see how to rearrange into the form $At^4 + Bt^3 + Ct^2 + Dt + E = 0$ so as to use a polynomial solver in a package such as numpy.
Below is the plot I made so far to view the intersecting shapes in question, and in case it is of help to anyone to check any suggested approaches, the values used to produce this diagram are:
$(X_c, Y_c) = (550, 1000)$; $r = 225$; $(x_c, y_c) = (1000, 1000)$; $a = 675$; $b = 275$.
Plugging in these values, I can reduce the substituted equation to the following, which Wolfram Alpha cannot find any simpler rearrangement of:
$\frac{(3t^2 + 1)^2}{9(t^2 + 1)^2} + \frac{324t^2}{121(t^2 + 1)} - \frac{1}{275}$
The intersection in question is between the lime green circle and the orange [inner] ellipse. From inspecting this plot, the intersection (x,y) coords are (592, 780) in the top left quadrant of the ellipse, and (592, 1220) in the bottom left quadrant of the ellipse.
The yellow arrow points to the midpoint of the major axis radius, which is the centre of the lime green circle. The orange ellipse represents the locus of all possible centre points of circles 'rolled around the inside' of the outer [black] ellipse.
I don't know how to proceed solving this as a pair of simultaneous equations, as it doesn't seem to be in a form amenable to factoring, nor solving as a polynomial (e.g. no clear coefficients for the fractions with terms in $t^4$ on both numerator and denominator).
I've checked the coordinates of $(592, 780)$ and $(1220, 780)$ with the parametric equations of the [lime green] circle, which give:
- $t = cos^{-1}(\frac{x - x_c}{r})$ ⇒ $t = cos^{-1}(\frac{592 - 1000}{225})$ = $4.9235998607438685$
- $t = cos^{-1}(\frac{x - x_c}{r})$ ⇒ $t = cos^{-1}(\frac{1220 - 1000}{225})$ = $1.3595854464357182$
and plotted this on the circumference of the circle accordingly (blue and red dot, respectively).

