Line Segment Intersection — Definition, Formula & Example
Line segment intersection is the point (or points) that two line segments share. Two segments can lie on lines that cross and still miss each other, because each segment stops at its endpoints.
For segments and in the plane, the intersection is the set . It is empty, a single point, or, when the segments are collinear and overlap, a segment. A point is in the intersection exactly when for some and with and .
Key Formula
Where:
- = Endpoints of the first segment
- = Endpoints of the second segment
- = Parameter along the first segment: t = 0 gives A and t = 1 gives B
- = Parameter along the second segment: s = 0 gives C and s = 1 gives D
Worked Example
Problem: Do the segment from A(0, 0) to B(8, 4) and the segment from C(2, 6) to D(6, -2) intersect? If so, where?
Step 1: Write each segment in parametric form. Here B − A = (8, 4) and D − C = (4, −8).
Step 2: Set the x-coordinates equal and the y-coordinates equal. Double the second equation to get 8t = 12 − 16s. Subtracting it from the first gives 0 = 20s − 10, so s = 1/2. Then t = (6 − 4)/4.
Step 3: Check the parameters. Both t and s lie between 0 and 1, so the point lies on both segments, not just on both lines. Substitute t = 1/2 to find the point.
Answer: Yes. The segments intersect at , the midpoint of each segment, since .
Why It Matters
Collision detection in video games and the hit tests in drawing software both rely on segment intersection tests. Computational geometry also uses them to check whether a polygon's edges cross themselves. In those settings, finding where the infinite lines meet gives the wrong answer whenever the segments stop short.
Common Mistakes
Mistake: Finding where the two lines meet and reporting that point without checking that it lies on both segments.
Correction: Always confirm that and . For example, the segment from (0, 0) to (2, 1) lies on a line through (4, 2), but that point needs . It lies past B, so this segment does not reach the segment from C(2, 6) to D(6, −2).
