How do you calculate the point where two lines in the plane intersect? It is not very hard to do, but the formula can look quite complicated, depending on how you write it up. This article is a reminder that it can be expressed in a simple manner.

We start out by not restricting ourselves to the plane, but any vector space with an inner product \langle \cdot, \cdot \rangle. Let two lines be represented as

(1)
\hbox{p} + s \hbox{v}, \quad s \in \mathbb{R}

and

\hbox{q} + t \hbox{w}, \quad t \in \mathbb{R}

where \hbox{p}, \hbox{q}, \hbox{v}, and \hbox{w} are vectors. We assume that both \hbox{v} and \hbox{w} are non-null. See Figure 1.

Figure 1

Figure 1. Line-line intersection


We look for values of s and t such that

(2)
\hbox{p} + s \hbox{v} = \hbox{q} + t \hbox{w}.

Let \hat{\hbox{w}} \neq 0 be a vector perpendicular to \hbox{w}, \langle \hbox{w}, \hat{\hbox{w}} \rangle = 0. We get

(3)
s \langle \hbox{v}, \hat{\hbox{w}} \rangle = \langle \hbox{q} – \hbox{p}, \hat{\hbox{w}} \rangle

Now if \langle \hbox{v}, \hat{\hbox{w}} \rangle = 0 there are two possibilities: If \langle \hbox{q} – \hbox{p}, \hat{\hbox{w}} \rangle = 0 there are infinitely many solutions, i.e., the lines overlap, but if \langle \hbox{q} – \hbox{p}, \hat{\hbox{w}} \rangle \neq 0 there are no solutions, i.e., the lines are parallel and do not intersect.

Assume then \langle \hbox{v}, \hat{\hbox{w}} \rangle \neq 0. We get

s = \frac{\langle \hbox{q} – \hbox{p}, \hat{\hbox{w}} \rangle}{\langle \hbox{v}, \hat{\hbox{w}} \rangle},

and thus, after inserting into (1), the point of intersection is

\hbox{p} + \frac{\langle \hbox{q} – \hbox{p}, \hat{\hbox{w}} \rangle}{\langle \hbox{v}, \hat{\hbox{w}} \rangle} \hbox{v}.

The Plane is Special

The derivation above is actually a little careless. If (2) is to hold for some s and t, then (3) must also hold. Turning the implication the other way, which we would like to, is less straightforward.

Assume that (3) holds for some value of s,

(4)
\langle s \hbox{v} + \hbox{p} – \hbox{q}, \hat{\hbox{w}} \rangle = 0.

What does this mean? It means that the vectors s \hbox{v} + \hbox{p} – \hbox{q} and \hat{\hbox{w}} are perpendicular to each other, and if we are in two dimensions/the plane we must have s \hbox{v} + \hbox{p} – \hbox{q} = t \hbox{w} for some value of t. This is (2) and we are done.

Does this work in higher dimensions? Generally, no. Consider, e.g., three dimensions and Equation (4). What can we derive of it now? We have that

s \hbox{v} + \hbox{p} – \hbox{q} = \alpha \hbox{w}_1 + \beta \hbox{w}_2

for some values of \alpha and \beta and where \langle \hbox{w}_1, \hat{\hbox{w}} \rangle = \langle \hbox{w}_2, \hat{\hbox{w}} \rangle = 0. And \alpha \hbox{w}_1 + \beta \hbox{w}_2 = t \hbox{w} does not necessarily hold for any t, so (2) does generally not follow in three dimensions or more.

Summary Using Coordinates

Let us consider the usual two-dimensional Euclidean space and Cartesian coordinates. We set

\hbox{p} = (p_1,p_2), \quad \hbox{q} = (q_1,q_2), \quad
\hbox{v} = (v_1,v_2), \quad \hbox{w} = (w_1,w_2),

and use the inner product

\langle (a_1,a_2), (b_1,b_2) \rangle = a_1 b_1 + a_2 b_2.

Rotating a vector \hbox{w} = (w_1,w_2) counterclockwise by a right angle is easily done with \hat{\hbox{w}} = (-w_2, w_1). It is easily checked that \langle \hbox{w}, \hat{\hbox{w}} \rangle = 0.

Recall that we are interested in knowing whether the two lines

(x,y) = (p_1,p_2) + s (v_1,v_2), \quad s \in \mathbb{R}

and

(x,y) = (q_1,q_2) + t (w_1,w_2), \quad t \in \mathbb{R}

intersect.

Setting \alpha = w_1 v_2 – w_2 v_1 and \beta = w_1 (q_2-p_2) – w_2 (q_1-p_1), we have

  • \alpha = 0, \beta = 0: The two lines overlap.
  • \alpha = 0, \beta \neq 0: The lines are parallel but do not intersect.
  • \alpha \neq 0: The lines meet at a single point, (p_1 + \frac{\beta}{\alpha} v_1, p_2 + \frac{\beta}{\alpha} v_2).
  • Share/Bookmark