Tag Archives: line intersection

Find the shortest distance between a point and a line segment in C#

This example treats the segment as parameterized vector where the parameter t varies from 0 to 1. It finds the value of t that minimizes the distance from the point to the line. If t is between 0.0 and 1.0, … Continue reading

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

Draw rainbow compound lines in WPF and C#

The post Make compound lines in WPF and C# shows how to make compound lines, lines that are striped lengthwise. Once you know how to do that, it’s easy to make rainbow compound lines. The following code shows how this … Continue reading

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

Make compound lines in WPF and C#

In order to draw an outlined path, the post Draw an outlined path in WPF and C# explained how to find the left and right edge points for a path. This post explains how to use those points to draw … Continue reading

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

Draw an outlined path in WPF and C#

Most of the techniques needed to draw an outlined path are included in those you need to draw compound lines. For the basic idea behind compound lines and a technique that lets you draw symmetric compound lines relatively easily, see … Continue reading

Posted in algorithms, drawing, graphics, mathematics | Tagged , , , , , , , , , , , , , , , , , | 3 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

Find the shortest distance between two line segments in C#

Click four points to pick the end points for the two line segments. The program finds the points on the two segments that are closest and connects them. The closest distance between two segments is either 0 if they intersect, … Continue reading

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

Determine where two lines intersect in C#

This example determines whether two segments intersect and where the lines that contain them intersect. There are several ways you can approach this problem. This example uses lines defined by parametric equations where 0 <= t1, t2 <= 1. If … Continue reading

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