[C# Helper]
Index Books FAQ Contact About Rod
[Beginning Database Design Solutions, Second Edition]

[Beginning Software Engineering, Second Edition]

[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

Title: 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 "See where two ellipses intersect in C#" explains how to find the points of intersections between two conic sections. You can find that post's pieces here:

Although that post focuses on finding points of intersections between two ellipses, the equations and methods it discusses work for any conic sections.

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 to experiment with it and to see additional details.

© 2009-2023 Rocky Mountain Computer Consulting, Inc. All rights reserved.