Tag Archives: ellipse

Calculate where a line segment and an ellipse intersect in C#

Finding the intersection between a line segment and an ellipse requires a lot of mathematics. It’s not particularly hard mathematics, but if you’d rather skip it, you can use the following links to jump to the other parts of this … Continue reading

Posted in algorithms, drawing, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , , , , , , | 5 Comments

Determine which pie slice is under the mouse in C#

When the program starts, the following code initializes the pie chart’s parameters. // The pie chart’s center. private Point EllipseCenter; // The pie chart’s drawing area. private Rectangle EllipseRect; // The ellipse’s X and Y radii. private float EllipseRx, EllipseRy; … Continue reading

Posted in algorithms, drawing, graphics, mathematics | Tagged , , , , , , , , , , , , , , | Leave a comment

Let the user draw rubber band ellipses (or other shapes) in C#

The following code shows how the program lets the user draw rubber band ellipses. // The ellipses to draw. private List<Rectangle> Ellipses = new List<Rectangle>(); // The points for the new ellipse we are drawing. private Point StartPoint, EndPoint; private … Continue reading

Posted in drawing, graphics | Tagged , , , , , , , , , | Leave a comment

Render an ellipse in a WPF program using C#

This example shows how you can render an ellipse in a WPF program. Normally to draw shapes in WPF you use some sort of object. You can add Ellipse, Line, Path, Polygon, Polyline, and Rectangle objects to a window and … Continue reading

Posted in drawing, geometry, graphics, wpf, XAML | Tagged , , , , , , , , , , , , , | 2 Comments

Draw on a bitmap in C#

This example shows how you can draw on a bitmap and display the result on a form. The example Draw in a Paint event handler in C# shows how to draw in a form’s Paint event handler. This is simple, … Continue reading

Posted in drawing, graphics | Tagged , , , , , , , , , , , | 1 Comment

Draw in a Paint event handler in C#

Using images and drawing in the Paint event handler are the two most common ways to display graphics. Drawing in the Paint event handler is easy, but there are a couple of things you should keep in mind when you … Continue reading

Posted in drawing, graphics | Tagged , , , , , , , , , , , | 11 Comments

See where a line intersects a conic section in C#

This example shows how you can see where a line intersects a conic section. You can use the more general method described in the post See where two conic sections intersect in C#. This example takes advantage of the simpler … Continue reading

Posted in algorithms, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , , , , | Leave a comment

See where two conic sections intersect in C#

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 … Continue reading

Posted in algorithms, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , , , , , , , , , , | 1 Comment

Select a conic section in C#

This example shows how you can let the user click five points to select a conic section. Recall that the equation for a conic section is: If you know the coordinates of some points on a conic section, then you … Continue reading

Posted in algorithms, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Draw a conic section from its polynomial equation in C#

This example shows how to draw a conic section from its polynomial equation. A previous series of posts explained how to find the intersection between two ellipses. See these posts for more information about that: See where two ellipses intersect … Continue reading

Posted in algorithms, geometry, graphics, mathematics | Tagged , , , , , , , , , , , , , , , , , , , | 2 Comments