Mathwords logoMathwords

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 AB‾\overline{AB} and CD‾\overline{CD} in the plane, the intersection is the set AB‾∩CD‾\overline{AB} \cap \overline{CD}. It is empty, a single point, or, when the segments are collinear and overlap, a segment. A point PP is in the intersection exactly when P=A+t(B−A)=C+s(D−C)P = A + t(B - A) = C + s(D - C) for some tt and ss with 0≤t≤10 \le t \le 1 and 0≤s≤10 \le s \le 1.

Key Formula

A+t(B−A)=C+s(D−C),0≤t≤1,    0≤s≤1A + t(B - A) = C + s(D - C), \qquad 0 \le t \le 1,\;\; 0 \le s \le 1
Where:
  • A,BA, B = Endpoints of the first segment
  • C,DC, D = Endpoints of the second segment
  • tt = Parameter along the first segment: t = 0 gives A and t = 1 gives B
  • ss = 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).
AB‾:(8t,  4t),CD‾:(2+4s,  6−8s)\overline{AB}: (8t,\; 4t), \qquad \overline{CD}: (2 + 4s,\; 6 - 8s)
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.
8t=2+4s,4t=6−8s  ⟹  s=12,  t=128t = 2 + 4s, \quad 4t = 6 - 8s \implies s = \tfrac{1}{2},\; t = \tfrac{1}{2}
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.
(8⋅12,  4⋅12)=(4, 2)\left(8 \cdot \tfrac{1}{2},\; 4 \cdot \tfrac{1}{2}\right) = (4,\, 2)
Answer: Yes. The segments intersect at (4,2)(4, 2), the midpoint of each segment, since t=s=12t = s = \tfrac{1}{2}.

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 0≤t≤10 \le t \le 1 and 0≤s≤10 \le s \le 1. For example, the segment from (0, 0) to (2, 1) lies on a line through (4, 2), but that point needs t=2t = 2. It lies past B, so this segment does not reach the segment from C(2, 6) to D(6, −2).

Related Terms

  • Line-Line Intersection — Finds where full lines cross, before the endpoint check
  • Line Segment — Defines the bounded objects whose crossing is tested here
  • Coordinate Plane — Setting where segment endpoints and crossings are located
  • Analytic Geometry — Field that solves geometry problems like this algebraically
  • Endpoint — Endpoints limit where segments can actually meet