Note that there are some explanatory texts on larger screens.

plurals
  1. PODetecting coincident subset of two coincident line segments
    primarykey
    data
    text
    <p>This question is related to:</p> <ul> <li><a href="https://stackoverflow.com/questions/153592/how-do-i-determine-the-intersection-point-of-two-lines-in-gdi">How do I determine the intersection point of two lines in GDI+?</a> (great explanation of algebra but no code)</li> <li><a href="https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/563240#563240">How do you detect where two line segments intersect?</a> (accepted answer doesn't actually work)</li> </ul> <p>But note that an interesting sub-problem is completely glossed over in most solutions which just return null for the coincident case even though there are three sub-cases:</p> <ul> <li>coincident but do not overlap</li> <li>touching just points and coincident</li> <li>overlap/coincident line sub-segment</li> </ul> <p>For example we could design a C# function like this:</p> <pre><code>public static PointF[] Intersection(PointF a1, PointF a2, PointF b1, PointF b2) </code></pre> <p>where (a1,a2) is one line segment and (b1,b2) is another.</p> <p>This function would need to cover all the weird cases that most implementations or explanations gloss over. In order to account for the weirdness of coincident lines, the function could return an array of PointF's:</p> <ul> <li>zero result points (or null) if the lines are parallel or do not intersect (infinite lines intersect but line segments are <b>disjoint</b>, or lines are <b>parallel</b>)</li> <li>one result point (containing the intersection location) if they do <b>intersect</b> or if they are <b>coincident</b> at one point</li> <li>two result points (for the <b>overlapping</b> part of the line segments) if the two lines are <b>coincident</b></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload