Intersection of arbitrary ellipses.

Background to the creation of this sketch

Back in 2016 I came across this article which described the closed-form solution for the intersections of two arbitary ellipses. I tried to implement it with Java but without immediate success so I put it to one side and forgot about it. Now 7 years later while reorganising my bookmarks I come across the article again and this time decided to make a serious effort to implement their solution.

Again I had little success implementing the code in the article and was not sure whether it was an error on my part or in the article. I decided that the only thing to do was to start from scratch.

I knew that finding the intersections required complex number maths and solving quartic equations such as -
\[a_4 x^4+a_3 x^3+a_2 x^2+a_1 x+a_0 = 0\]

I also discovered that solving the quartic equation also required solving cubic and quadratic equations as well. So it has been much more challenging than I first expected but you can see the result in action above.

It should not be surprising that the code also finds ellipse-circle and circle-circle intersections, after all a cicle is just special case of an ellipse.

I have documented the maths I used whilst creating this sketch because it would be useful if I decided to extend the codebase. If you are interested you can see it in this article.

The source code is freely available at Open Processing or at p5.js Web Editor