Skip to content
Search

Line–line intersection

lastmod 2024-03-07created 2017-12-157 edits

In Euclidean geometry, the intersection of a line and a line can be the empty set, a point, or a line. Distinguishing these cases and finding the intersection point have use, for example, in computer graphics, motion planning, and collision detection.

In three-dimensional Euclidean geometry, if two lines are not in the same plane they are called skew lines and have no point of intersection. If they are in the same plane there are three possibilities: if they coincide (are not distinct lines) they have an infinitude of points in common (namely all of the points on either of them); if they are distinct but have the same slope they are said to be parallel and have no points in common; otherwise they have a single point of intersection.

The distinguishing features of non-Euclidean geometry are the number and locations of possible intersections between two lines and the number of possible lines with no intersections (parallel lines) with a given line.

Intersection of two lines in General Form

Rearrange into x and y terms for readability.

First line:

\(\begin{align} & Ax + By + C = 0 \\ & x = -B/Ay - C/A \tag{1} \\ & y = -A/Bx - C/B \tag{2} \\ \end{align}\)

Second line:

\(\begin{align} & Dx + Ey + F = 0 \\ & x = -E/Dy - F/D \tag{3} \\ & y = -D/Ex - F/E \tag{4} \\ \end{align}\)

The x and y values of the intersection point P satisfy both lines when substituted.

Eliminate the unknown x:

\(\begin{align} & (1) = (3) \\ & -B/Ay - C/A = -E/Dy - F/D \\ & E/Dy - B/Ay = C/A - F/D \\ & (E/D - B/A)y = (C/A - F/D) \\ & y = (C/A - F/D) / (E/D - B/A) \\ \end{align}\)

Simplify the right-hand side:

\({\displaystyle \begin{align} y &= (C/A - F/D) / (E/D - B/A) \\ &= \frac{\frac{C}{A} - \frac{F}{D}}{\frac{E}{D} - \frac{B}{A}} \\ &= \frac{\frac{CD}{AD} - \frac{AF}{AD}}{\frac{AE}{AD} - \frac{BD}{AD}} \\ &= \frac{\frac{CD - AF}{AD}}{\frac{AE - BD}{AD}} \\ &= \frac{CD - AF}{AD} / \frac{AE - BD}{AD} \\ &= \frac{CD - AF}{AD} * \frac{AD}{AE - BD} \\ &= \frac{(CD - AF) * AD}{AD * (AE - BD)} \\ &= \frac{CD - AF}{AE - BD} \\ &= (CD - AF) / (AE - BD) \\ \end{align} }\)

Eliminate the unknown y:

\(\begin{align} & (2) = (4) \\ & -(Ax + C) / B = -(Dx + F) / E \\ & Dx/E - Ax/B = C/B - F/E \\ & (D/E - A/B)x = (C/B - F/E) \\ & x = (C/B - F/E) / (D/E - A/B) \\ \end{align}\)

Simplify the right-hand side:

\({\displaystyle \begin{align} x &= (C/B - F/E) / (D/E - A/B) \\ &= \frac{ \frac{C}{B} - \frac{F}{E} }{ \frac{D}{E} - \frac{A}{B} } \\ &= \frac{ \frac{CE}{BE} - \frac{BF}{BE} }{ \frac{BD}{BE} - \frac{AE}{BE} } \\ &= \frac{ \frac{CE - BF}{BE} }{ \frac{BD - AE}{BE} } \\ &= \frac{CE - BF}{BE} / \frac{BD - AE}{BE} \\ &= \frac{CE - BF}{BE} * \frac{BE}{BD - AE} \\ &= \frac{(CE - BF) * BE}{BE * (BD - AE)} \\ &= \frac{CE - BF}{BD - AE} \\ &= (CE - BF) / (BD - AE) \\ \end{align} }\)

So the final answer is:

  • x = (CE - BF) / (BD - AE)
  • y = (CD - AF) / (AE - BD)

Alternatively, if you have already found x, you can substitute it into another equation.

Applied to term (4): y = -D/E * ((CE - BF) / (BD - AE)) - F/E

In this case, if the denominator (BD - AE) is 0, the lines are parallel or coincident.

See also

Favorite site

References


  1. Geometry_Concepts_-Line_Intersection_and_its_Applications-_topcoder.pdf ↩

author Zer0 sitemap