See where a parabola and hyperbola intersect in C#

See where a parabola and hyperbola intersect

This example shows how to see where a parabola and hyperbola intersect. The previous four-part example
here, here, here, and here explains how to find the points of intersections between two conic sections. Although the posts focus on finding points of intersections between two ellipses, they equations and methods they discuss work for any conic section.

This example uses the techniques demonstrated by the earlier example to find the points of intersections between a parabola and a hyperbola. This example is similar to the previous one so see them for more information. The big difference in this example is that you cannot click and drag to select ellipses. Instead the program’s Load event handler uses the following code to initialize the variables A1, B1, C1, D1, E1, and F1 to define a parabola, and A2, B2, C2, D2, E2, and F2 to define a hyperbola.

private void Form1_Load(object sender, EventArgs e)
{
    this.DoubleBuffered = true;
    TangentX = 88;

    // A parabola.
    float dx = 50;
    float dy = 100;
    float sx = 10;
    float sy = 1;

    A1 = 0;
    B1 = 0;
    C1 = -sy * sy;
    D1 = sx;
    E1 = 2 * sy * dy;
    F1 = -sx * dx - dy * dy;

    // A hyperbola.
    dx = HyperbolaXmid;
    dy = 70;
    float a2 = 50;
    float b2 = 150;
    A2 = 1 / a2;
    B2 = 0;
    C2 = -1 / b2;
    D2 = -2 * dx / a2;
    E2 = 2 * dy / b2;
    F2 = (dx * dx / a2) - (dy * dy / b2) - 1;

    // Perform the calculations.
    PerformCalculations();
}

Download the example and see the previous posts for additional details about how the calculations work.


Download Example   Follow me on Twitter   RSS feed   Donate




This entry was posted in algorithms, geometry, graphics, mathematics and tagged , , , , , , , , , , , , . Bookmark the permalink.

3 Responses to See where a parabola and hyperbola intersect in C#

  1. I’m finding the greedy mesh part a bit hard to follow without some sample code.

Leave a Reply

Your email address will not be published. Required fields are marked *