Can you list me all the geometrical conditions of two ellipses with a common focus?

349 Views Asked by At

I'm dealing with a mathematics/astrodynamics problem that consist into writing a Matlab code that computes the possible intersections of two ellipses with a common focus. I'm writing a series of if-statements but I'm having trouble to set all conditions. I have to cover all possible cases, i.e., ellipses contained one inside the other (no intersections), the case of same line of apsides, all the cases of tangency condition, all cases of two intersection points and so on. Can you help me?

Here is my code, but it requires some adjustments:

clear all; close all; clc;

global tol twopi
a1=200000;
e1=0.6;
a2 =250000;
e2=0.4;
D_omega=0;  % difference between pericenters

tol   = 1.e-30; % tolerance for numeric zero
twopi = pi + pi;



% Solutions initialization
xiA = 0.0;
yiA = 0.0;
xiB = 0.0;
yiB = 0.0;

cosDomeg = cos(D_omega);
sinDomeg = sin(D_omega);
p1 = a1*(1.0-e1*e1);  % semilatus rectum
p2 = a2*(1.0-e2*e2);

r_p1 = a1*(1.0-e1);   % pericenter radius
r_a1 = a1*(1.0+e1);   % apocenter radius
r_p2 = a2*(1.0-e2);
r_a2 = a2*(1.0+e2);

if(r_a1 < r_p2)     % ellipse 1 contained inside ellipse 2
    nSol = 0;
    str = 'ellipse 1 contained inside ellipse 2';
elseif(r_a2 < r_p1) % ellipse 2 contained inside ellipse 1
    nSol = 0;
    str = 'ellipse 2 contained inside ellipse 1';
elseif(r_p1 < r_p2 && r_a1 < r_a2 && abs(D_omega) < tol) % two ellipses with same apse line (Delta theta = 0), ellipse 1 contained inside ellipse 2
    nSol = 0;
elseif(r_p2 < r_p1 && r_a2 < r_a1 &&  abs(D_omega) < tol) % two ellipses with same apse line (Delta theta = 0), ellipse 2 contained inside ellipse 1
    nSol = 0;
elseif(abs(p2-p1) < tol && abs(e2-e1) < tol && abs(D_omega) < tol)  % two identical ellipses
    % identical ellipses
    nSol = -1;
else
    a = p1-p2;
    b  = p1*e2*cosDomeg-p2*e1;
    c = -p1*e2*sinDomeg;
    
    % general solution
    k1 = b*b + c*c;
    k2 = a*b;
    k3 = a*a - c*c;

    discr = k2*k2 - k1*k3;
    
    
    if(discr < tol) % they do not intersect  !!!(qui non dovrebbe essere discr<tol ?)!!!!
        nSol = 0;
        str = 'delta negative: no intersections';
    elseif(abs(discr) < tol && abs(sinDomeg) > tol)
        % the discriminant is null and the two axes are neither parallel nor
        % antiparallel
        % TWO IDENTICAL SOLUTIONS (tangency point)
        nSol = 1;
        cth1 = -k2/k1;
        sth1 = (a + b*cth1)/c;
        cth2 = cth1;
        sth2 = sth1;
        str = 'delta = 0: two identical solutions!';
    else
        % TWO DISTINCT SOLUTIONS
        nSol = 2;
        if(abs(sinDomeg) > tol) 
            cth1 = (-k2 + sqrt(discr))/k1;
            cth2 = (-k2 - sqrt(discr))/k1;
            sth1 = (a + b*cth1)/c;
            sth2 = (a + b*cth2)/c;
            str = '2 solutions: general case';
        else  
            if(abs(a/b - 1) < tol)  % ellipses are parallel or anti-parallel and are tangent at theta = 180 (apocenter)
                nSol = 1;
                cth1 = -1.0;
                cth2 = cth1;
                sth1 = 0.0;
                sth2 = 0.0;
                str = '1 solution: tangency at apocenter';
            elseif(abs(a/b + 1) < tol)  % ellipses are parallel or anti-parallel and  are tangent at theta = 0 (pericenter)
                nSol = 1;
                cth1 = 1.0;
                cth2 = cth1;
                sth1 = 0.0;
                sth2 = 0.0;
                str = '1 solution: tangency at pericenter';
            else  % special case: same apse line with 2 distinct solutions 
                cth1 = -a/b;
                cth2 = cth1;
                sth1 = (1 - cth1^2)^0.5;
                sth2 = -sth1;
                str = '2 solution: same apse line';
            end
        end
        th1 = atan2(sth1,cth1);
        th1 = mod(th1,twopi);
        th2 = atan2(sth2,cth2);
        th2 = mod(th2,twopi);
        
        %Compute coordinates of intersection points in the perifocal r.f.
        %of ellipse 1
        [xiA,yiA] = Get_perifocal_coordinates(a1,e1,th1);
        [xiB,yiB] = Get_perifocal_coordinates(a1,e1,th2);    
        
    end
end

P.S. My work activity: Study possbile intersections between asteroids and Keplerian orbits derived by propagation of Invariant Manifolds computed starting from Lyapunov orbits (by assuming to be outisde of the circle of influence of the Earth and not sphere since I'm considering the simpe 2D case). So, we are in heliocentric perspective, within the ecliptic plane (with a good approximation).

3

There are 3 best solutions below

2
On BEST ANSWER

From the context of astrodynamics, I assume you're trying to solve the problem of finding the intersection points of two coplanar ellipses that share one focus. (As was pointed out in the comments, "confocal" usually refers to ellipses sharing both foci.)

In polar coordinates, two ellipses with one focus at the origin are given by $$ r_1(\theta) = \frac{c_1}{1 + \epsilon_1 \cos \theta} \qquad r_2(\theta) = \frac{c_2}{1 + \epsilon_2 \cos (\theta - \delta)} $$ where $\delta$ is the angle of the pericenter of ellipse #2 (assuming we have chosen our coordinates so that the pericenter of ellipse #1 is at $\theta = 0$), the $c_i$'s are the semi-latus rectums (semi-lati recta?), and the $\epsilon_i$'s are the eccentricities.

Demanding that these two quantities be equal, and defining $\rho = c_1/c_2$, leads to reduces to $$ 1 + \epsilon_1 \cos \theta = \rho \left( 1 + \epsilon_2 \cos (\theta - \delta) \right) \\ 1- \rho = \rho \epsilon_2 \cos(\theta - \delta) - \epsilon_1 \cos \theta $$ After an annoying amount of trig identities, the right-hand side of this equation can be transformed to $$ 1 - \rho = \sqrt{ \rho^2 \epsilon_2^2 + \epsilon_1^2 - 2 \rho \epsilon_1 \epsilon_2 \cos \delta} \cos(\theta - \alpha) $$ where $\alpha$ is defined by $$ \tan \alpha = \frac{\rho \epsilon_2 \sin \delta}{\rho \epsilon_2 \cos \delta - \epsilon_1}$$

We can see from this equation that:

  • If $|1 - \rho| > \sqrt{ \rho^2 \epsilon_2^2 + \epsilon_1^2 - 2 \rho \epsilon_1 \epsilon_2 \cos \delta}$, there are no solutions, and the ellipses do not intersect.
  • If $|1 - \rho| = \sqrt{ \rho^2 \epsilon_2^2 + \epsilon_1^2 - 2 \rho \epsilon_1 \epsilon_2 \cos \delta}$, then there is one solution when $\theta = \alpha$ or when $\theta = \alpha + \pi$, depending on whether $1 - \rho$ is positive or negative. The ellipses will be tangent at this point.
  • If $|1 - \rho| < \sqrt{ \rho^2 \epsilon_2^2 + \epsilon_1^2 - 2 \rho \epsilon_1 \epsilon_2 \cos \delta}$, then there are two intersection points at angles $$ \theta = \alpha \pm \arccos \left[ \frac{1 - \rho}{\sqrt{ \rho^2 \epsilon_2^2 + \epsilon_1^2 - 2 \rho \epsilon_1 \epsilon_2 \cos \delta}} \right]. $$
0
On

Two confocal ellipses are of the form

$ \dfrac{x^2}{a_1^2} + \dfrac{y^2}{b_1^2} = 1 $

and

$ \dfrac{x^2}{a_2^2} + \dfrac{y^2}{b_2^2} = 1 $

Since the two foci (assumed to be on the $x$ axis) then

$ a_1^2 - b_1^2 = a_2^2 - b_2^2 = f^2$

where $f$ is distance between a focus and the origin.

If these two ellipses intersect at a point $(x, y)$ then

$ x^2 \left( \dfrac{1}{a_1^2} - \dfrac{1}{a_2^2} \right) + y^2 \left( \dfrac{1}{b_1^2} - \dfrac{1}{b_2^2} \right) = 0 $

And this equation reduces to

$ x^2 \left( \dfrac{a_2^2 - a_1^2}{a_1^2 a_2^2} \right) + y^2 \left( \dfrac{b_2^2 - b_1^2}{b_1^2 b_2^2} \right) = 0 $

Since $a_2^2 - a_1^2 = b_2^2 - b_1^2 $ both terms have the same sign, and this implies that the only possible solution is $x = y = 0 $, but the point $(0,0)$ does not lie on either ellipse; in other words the solution $(0,0)$ is an extraneous solution. Thus these two ellipses do not intersect.

0
On

Converting my comment to @MichaelSeifert's answer to its own answer, as I think it's helpful.

As with @Michael's solution, start with the polar equations of the ellipses with foci at the origin, one with its major axis aligned with the $x$-axis, and one with its major axis inclined at angle $\delta$ from the $x$-axis. Observe that each latus rectum ($c_i$ there) can be written $a_i(1-e_i^2)$, where $a_i$ is the corresponding major radius and $e_i$ the eccentricity; so we have $$r_1 = \frac{a_1(1-e_1^2)}{1+e_1\cos\theta} \qquad r_2 = \frac{a_2(1-e_2^2)}{1+e_2\cos(\theta+\delta)}$$ Equating $r_1=r_2$, expanding $\cos(\theta+\delta)$ and using the tangent half-angle substitution $$t := \tan\frac12\theta \qquad \cos\theta = \frac{1-t^2}{1+t^2} \qquad \sin\theta = \frac{2t}{1+t^2}$$ gives the quadratic $$\begin{align} 0 = &\phantom{-2\;}t^2\,(1 - e_1) (a_1 (1 + e_1) - a_2 (1 - e_2^2) - a_1 (1 + e_1) e_2 \cos\delta ) \\ &-2 t\,a_1 (1 - e_1^2) e_2 \sin\delta \\ &+\phantom{2t}(1 + e_1) (a_1 (1 - e_1) - a_2 (1 - e_2^2) + a_1 (1 - e_1) e_2 \cos\delta) \end{align}$$ with discriminant $$4 (1 - e_1^2)(1 - e_2^2)\;\left( a_1^2 e_1^2 + a_2^2 e_2^2- 2 a_1e_1 a_2e_2 \cos\delta -(a_1-a_2)^2 \right)$$ Assuming we have ellipses ($e_i<1$), the first three factors are positive, so the final factor's sign determines the number of solutions. (Positive: two solutions; zero: one double-solution (ie, a tangency); negative: no solutions.) Note that $a_ie_i$ is the focus-to-center length in an ellipse; consequently, the Law of Cosines allows us to rewrite that final factor as

$$p^2 - (a_1-a_2)^2 = (p-a_1+a_2)(p+a_1-a_2)$$

where $p$ is the distance between the centers of the ellipses. So, determining the number of solutions is a simple matter of checking the sign of that product.

Note. The product is positive when the factors have the same sign; since the individual lengths $p$, $a_1$, $a_2$ are non-negative, the factors can't both be negative. The assertion that the two factors are positive, along with the necessary fact that $p\leq a_1 e_1 + a_2 e_2 <a_1+a_2$, constitute the three aspects of the Triangle Inequality with our lengths. Consequently, we have the following geometric interpretation of the solution cases:

  • The ellipses have two distinct points of intersection if $p$, $a_1$, $a_2$ form a non-degenerate triangle.
  • The ellipses are tangent if $p$, $a_1$, $a_2$ form a degenerate ("flat") triangle.
  • The ellipses have no intersection if $p$, $a_1$, $a_2$ do not form a triangle (degenerate or non-).