This example uses techniques demonstrated in several earlier posts to let you see where two conic sections intersect.

To use the example, click the left mouse button five times each to select one conic section> Then click the right mouse button five times to select the second conic section. The program then uses the techniques demonstrated by the example Select a conic section in C# to find the equations for the conic sections that satisfy the points selected by the user.

(As in that example, this program doesn’t worry about weird cases such as when the user selects points that all have the same X coordinate.)

After a conic section has been selected, the program uses the techniques demonstrated by the example Draw a conic section from its polynomial equation in C# to draw it.

After the user has selected both conic sections, the program uses the techniques demonstrated by the example See where two ellipses intersect in C#, Part 4 to find the points of intersection between the two conic sections.

This code still sometimes has problems finding all of the possible zeros for the difference equations. You can work on making the code more robust if you like, but this is good enough to show the general technique.

Taken all together, this example is fairly complicated. It uses these techniques:

- It uses Gaussian elimination (twice) to find the equation for the conic section that satisfies five points selected by the user.
- It examines several cases of positive and negative roots to draw the equations of the conic sections.
- It calculates the difference equations between the equations of the two conic sections.
- It uses binary division (or Newton’s method) to find roots of the difference equations.

Individually the steps are non-trivial but manageable. When you put them together, you get this fairly complicated program for finding conic section intersections.

Pingback: See where a line intersects a conic section in C# - C# HelperC# Helper