Line-Line Intersection

DOWNLOAD Mathematica Notebook LineLineIntersection

The intersection of two lines L_1 and L_2 in two dimensions with, L_1 containing the points (x_1,y_1) and (x_2,y_2), and L_2 containing the points (x_3,y_3) and (x_4,y_4), is given by

x=(||x_1 y_1; x_2 y_2| |x_1 1; x_2 1|; |x_3 y_3; x_4 y_4| |x_3 1; x_4 1||)/(||x_1 1; x_2 1| |y_1 1; y_2 1|; |x_3 1; x_4 1| |y_3 1; y_4 1||)=(||x_1 y_1; x_2 y_2| x_1-x_2; |x_3 y_3; x_4 y_4| x_3-x_4|)/(|x_1-x_2 y_1-y_2; x_3-x_4 y_3-y_4|)
(1)
y=(||x_1 y_1; x_2 y_2| |y_1 1; y_2 1|; |x_3 y_3; x_4 y_4| |y_3 1; y_4 1||)/(||x_1 1; x_2 1| |y_1 1; y_2 1|; |x_3 1; x_4 1| |y_3 1; y_4 1||)=(||x_1 y_1; x_2 y_2| y_1-y_2; |x_3 y_3; x_4 y_4| y_3-y_4|)/(|x_1-x_2 y_1-y_2; x_3-x_4 y_3-y_4|),
(2)

where |a b; c d| denotes a determinant. This corresponds to simultaneously solving

|x y 1; x_1 y_1 1; x_2 y_2 1|=0
(3)
|x y 1; x_3 y_3 1; x_4 y_4 1|=0
(4)

for x and y. Other treatments are given by Antonio (1992) and Hill (1994).

The intersections of two lines given in trilinear coordinates as

l_1alpha+m_1beta+n_1gamma=0
(5)
l_2alpha+m_2beta+n_2gamma=0
(6)

is

 |m_1 m_2; n_1 n_2|:|n_1 n_2; l_1 l_2|:|l_1 l_2; m_1 m_2|.
(7)

Pseudocode for segment intersection is given by de Berg et al. (2000).

Three lines in trilinear coordinates

l_1alpha+m_1beta+n_1gamma=0
(8)
l_2alpha+m_2beta+n_2gamma=0
(9)
l_3alpha+m_3beta+n_3gamma=0
(10)

concur if their trilinear coordinates satisfy

 |l_1 m_1 n_1; l_2 m_2 n_2; l_3 m_3 n_3|=0,
(11)

in which case the point is

 m_2n_3-n_2m_3:n_2l_3-l_2n_3:l_2m_3-m_2l_3.
(12)

Three lines in Cartesian coordinates concur if the coefficients of the lines

A_1x+B_1y+C_1=0
(13)
A_2x+B_2y+C_2=0
(14)
A_3x+B_3y+C_3=0
(15)

satisfy

 |A_1 B_1 C_1; A_2 B_2 C_2; A_3 B_3 C_3|=0.
(16)

In three dimensions, the algebra becomes more complicated. The intersection of two lines containing the points x_1=(x_1,y_1,z_1) and x_2=(x_2,y_2,z_2), and x_3=(x_3,y_3,z_3) and x_4=(x_4,y_4,z_4), respectively, can also be found directly by simultaneously solving

x=x_1+(x_2-x_1)s
(17)
x=x_3+(x_4-x_3)t
(18)

together with the condition that the four points be coplanar (i.e., the lines are not skew),

 |x_1 y_1 z_1 1; x_2 y_2 z_2 1; x_3 y_3 z_3 1; x_4 y_4 z_4 1|=(x_3-x_1)·[(x_2-x_1)x(x_4-x_3)]=0
(19)

for x=(x,y,z), eliminating s and t. This set of equations can be solved for s to yield

 s=((cxb)·(axb))/(|axb|^2),
(20)

where

a=x_2-x_1
(21)
b=x_4-x_3
(22)
c=x_3-x_1
(23)

(Hill 1994).

The point of intersection can then be immediately found by plugging back in for s to obtain

 x=x_1+a((cxb)·(axb))/(|axb|^2).
(24)

A slightly more symmetrical and concise form can obtained by additionally defining

v=a^^xb^^
(25)
s_1=(det(c  b^^  v^^))/(|v|^2)
(26)
s_2=(det(c  a^^  v^^))/(|v|^2),
(27)

where x^^ denotes a unit vector, then

 x=1/2(x_1+a^^s_1+x_3+b^^s_2)
(28)

(Goldman 1990).

Wolfram Web Resources

Mathematica »

The #1 tool for creating Demonstrations and anything technical.

Wolfram|Alpha »

Explore anything with the first computational knowledge engine.

Wolfram Demonstrations Project »

Explore thousands of free applications across science, mathematics, engineering, technology, business, art, finance, social sciences, and more.

Computerbasedmath.org »

Join the initiative for modernizing math education.

Online Integral Calculator »

Solve integrals with Wolfram|Alpha.

Step-by-step Solutions »

Walk through homework problems step-by-step from beginning to end. Hints help you try the next step on your own.

Wolfram Problem Generator »

Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.

Wolfram Education Portal »

Collection of teaching and learning tools built by Wolfram education experts: dynamic textbook, lesson plans, widgets, interactive Demonstrations, and more.

Wolfram Language »

Knowledge-based programming for everyone.