[Contents]
Copyright © 2021 jsd

The Intersection of Two Lines
each represented by an anchor and a direction

John Denker

1  Preview

We shall see that it is sometimes advantageous to represent a line in the plane using four numbers, namely two vectors (with two components apiece), namely a position vector and a direction vector.

As a bonus, this approach allows us to represent not just the line as a whole, but also a special “anchor point” on the line. This is sometimes useful, e.g. to represent the “current” point or the “starting” point or some such.

For example, the point where two lines intersect is given by:

X = intersection point               
 = 
A + 
(BApB
pB·dA
 dA
     (1a)
 = 
B + 
(ABpA
pA·dB
 dB
     (1b)

The two expressions (equation 1a and equation 1b) are equivalent; you don’t need to evaluate both. The notation is explained in section 4.

Finding the intersection of two lines is a topic for high-school algebra, except that they do it without using vectors. In contrast, the last 999 times I wanted to find an intersection, the problem was already formulated in terms of vectors, and equation 1 was by far the most convenient way to proceed.

For example, suppose point A is a navigation fix or beacon, dA is a particular radial passing through that fix, B is your current position, and dB is your current velocity vector (aka heading). An autopilot or flight simulator might need to calculate the point of intersection, to predict where your path crosses the radial. (The actual calculation is more complicated than that, but even so, calculating intersections is one of the crucial ingredients.)

A spreadsheet that implements this calculation is given in reference 1.

intersecting-lines
Figure 1: Points of Intersection

2  Background

By way of context and background, here are some other representations that are sometimes encountered:

3  Discussion

Even though it “should” take only three numbers to represent a line with an anchor point, it is sometimes convenient to use four numbers, namely two vectors with two components apiece, namely a position vector (to specify the anchor point) and a direction vector (to specify the rest of the line).

position vector = A       
  = [AxAy]       (components)
             (2)

direction vector = dA     
  = [dAxdAy]               
  = |v| [sin(θ), cos(θ)]
             (3)

where θ is the heading, measured clockwise from north. Note: Mathematicians measure directions counterclockwise from east. In contrast, navigators measure headings clockwise from north, which is the convention used in equation 3.

Conceptually, we still require only three numbers, because we can impose a constraint. Without loss of generality, we can require the direction vector to be a unit vector, by setting |v|=1 in the last line of of equation 3.

On the other hand, sometimes it is advantageous to think in terms of a velocity vector (rather than a direction vector), in which case we really do need four numbers (two vectors) to specify what’s going on. Things get weird if the velocity is zero, in which case the heading is undefined and we don’t have a line at all; instead we just have an isolated point.

4  Derivation: Intersection of Two Lines

Suppose we have two lines:

A(α) = A + α dA       
B(β) = B + β dB
             (4)

for all α and β. To find the intersection, we need to find values of α and β such that

A + α dA = B + β dB
             (5)

or equivalently

A − B + α dA − β dB = 0
             (6)

this is a vector equation, so it counts as two equations in two unknowns, so it is well-posed (provided the two lines are not parallel).

We can convert this into a pair of scalar equations as follows:

(ABpA + 000 − β dB·pA = 0       
(ABpB + α dA·pB − 000 = 0
             (7)

where pA is a vector formed by rotating dA by 90 degrees. We then solve:

β = 
(ABpA
dB·pA
        
α = 
(BApB
dA·pB
             (8)

So the intersection occurs at:

X = intersection point               
 = 
A + 
(BApB
pB·dA
 dA
     (9a)
 = 
B + 
(ABpA
pA·dB
 dB
     (9b)

5  Ramifications

5.1  Check the Work

We can improve our understanding of this by performing some simple checks:

5.2  Projection-like Operator

The expression for XA is hauntingly similar (but not identical) to a projection operator acting on BA. Using Dirac bra-ket notation to distingish row vectors from column vectors, we have:

|XA = 
|dA⟩⟨pB|
dA|pB
 |BA
     (10a)
 = 
     |dA⟩⟨pB|
Tr |dA⟩⟨pB|
 |BA
     (10b)

If nothing else, this makes it easy to remember the formula. The pattern is:

There’s probably an elegant geometrical interpretation of this operator, i.e. some concept that captures the general notion of outer product divided by inner product, including projection operators as a special case.... However, I’m not grasping the general case at the moment.

6  References

1.
John Denker,
“Spreadsheet to Calculate Intersecting Lines”
./intersecting-lines.xls
[Contents]
Copyright © 2021 jsd