Finding Intersection of an ellipse with another ellipse when both are rotated

12.7k Views Asked by At

Equation of first ellipse=>

$$\dfrac {((x-xFirstEllipseCenterPoint)\cdot \cos(A)+(y-yFirstEllipseCenterPoint)\cdot \sin(A))^2}{(a_1^2)}+\dfrac{((x-xFirstEllipseCenterPoint)\cdot \sin(A)-(y-yFirstEllipseCenterPoint)\cdot \cos(A))^2}{(b_1^2)}=1$$


Equation of the second ellipse=>

$$\dfrac {((x-xSecondEllipseCenterPoint)\cdot \cos(B)+(y-ySecondEllipseCenterPoint)\cdot \sin(B))^2}{(a_2^2)}+\dfrac{((x-xSecondEllipseCenterPoint)\cdot \sin(B)-(y-ySecondEllipseCenterPoint)\cdot \cos(B))^2}{(b_2^2)}=1$$


I know that the ellipse will intersect at

  1. One Point
  2. Two Point
  3. Three Point
  4. Four Point
  5. No intersection at all

Is there a general set of equation to solve the same.

2

There are 2 best solutions below

8
On

J. Richter-Gebert's Perspectives on Projective Geometry section 11.4 gives a general recipe for intersecting conics. It also agrees with what Wikipedia has to say on intersecting conics. A rough outline is the following:

  1. Turn your conics into symmetric matrices $A$ and $B$ in $\mathbb R^{3\times3}$ such that a point with coordinates $(x,y)$ lies on them if $$(x,y,1)\cdot A\cdot\begin{pmatrix}x\\y\\1\end{pmatrix}=0 \quad\text{and}\quad (x,y,1)\cdot B\cdot\begin{pmatrix}x\\y\\1\end{pmatrix}=0$$ You can compute this form from your equations, with a bit of work. The comment below will help you with this; for parabolas see also this answer.

  2. Find a linear combination $C=\lambda A+\mu B$ such that $(\lambda,\mu)\neq(0,0)$ and $\det(C)=0$. This involves solving a cubic equation, so there will in general be three solutions. In this solution counting I've identified multiples of the same matrix, since these represent the same conic. Unless $A$ itself is already degenerate, you can assume $\mu=1$ so that you have a cubic equation in $\lambda$ only. Some solutions might not be real, which accounts for some of the different cases you mentioned.

  3. These three solutions correspond to three degenerate conics through the four points of intersection of $A$ and $B$. A degenerate conic in this sense is a product of two lines. These two lines might coincide, or be complex, which again corresponds to some of the case distinctions you mentioned.

  4. To obtain a pair of lines from the matrix of a degenerate conic, you have to add an antisymmetric matrix in such a way that the resulting matrix has rank $1$. This means that the determinants of all $2\times2$ minors of the resulting matrix have to be zero. This antisymmetric matrix has three parameters, for which you can formulate nine equations.

If you don't feel like solving nine (non-linear) equations, you can also do the following: compute the adjugate matrix of $C$. This will be a symmetric matrix of rank $1$. Take any nonzero row or column. Rows or columns only differ by a scalar factor. These coordinates you just obtained correspond to the homogenous coordinates of the point where the two lines intersect, which I'll call $p$. Then a suitably chosen multiple of these coordinates will correspond to the entries of your antisymmetric matrix. Written in formulas:

$$ \operatorname{adj}(C) = pp^T \qquad p = \begin{pmatrix}p_1\\p_2\\p_3\end{pmatrix} \qquad P = \begin{pmatrix} 0 & p_3 & -p_2 \\ -p_3 & 0 & p_1 \\ p_2 & -p_1 & 0 \end{pmatrix} \\ C' = C+\alpha P \qquad \operatorname{rank}(C') = 1 $$

In this case, you only need to solve a single quadratic equation to compute $\alpha$. You can use an arbitrary $2\times2$ minor to obtain this equation for $\alpha$. You will obtain two solutions which differ only by their sign, and you can choose either one.

Using either approach (3 parameters or using the adjugate matrix), you end up with a rank $1$ matrix describing the same degenerate conic. Any non-zero row of that matrix will be one of its component lines, any non-zero column the other. So now you have split the degenerate conic into two constituent lines.

  1. You can now either intersect these lines with the conic (a conic-line intersection is described in section 11.3) or use two different solutions (from step 2.) to obtain two different pairs of lines and then intersect these lines, one from each pair, to obtain the four points of intersection. The approach intersecting pairs of lines might require the use of complex lines even if their intersection points might turn out to be real, so you'd best do all the computations using complex numbers, and only discard complex final results at the very end. The easiest way to intersect these lines is by computing their cross product and dehomogenize the result.

Cross references:

1
On

Another approach ...

Your first ellipse can be described by the parametric equations: $$ x = H_1 + a_1\cos A \cos\theta - b_1 \sin A \sin\theta \\ y = K_1 + a_1\sin A \cos\theta + b_1 \cos A \sin\theta $$ If we let $t = \tan \tfrac12\theta$, then $$ \cos\theta = \frac{1-t^2}{1+t^2} \quad ; \quad \sin\theta = \frac{2t}{1+t^2} $$ Substititing into the equations above gives rational quadratic expressions for $x$ and $y$ that describe the first ellipse.

Substitute these expressions for $x$ and $y$ into the equation of the second ellipse, and simplify. After a lot of algebra, you will get a quartic equation in $t$ whose roots describe the intersection points.

There are formulas that give the solutions of a quartic equation, but I would recommend that you use numerical methods, instead. There are many available software packages that will do the job. Ask again here if you need help finding one.