Line-line intersection

Given two lines in 3D, defined as rays:

r1(t1)=p1+t1d1r2(t2)=p2+t2d2

Where t1,t2R, the two lines intersect if:

p1+t1d1=p2+t2d2

We can apply the cross multiplication operation on both sides with d2 and work from there to find the value of t1.

t1=|(p2p1)×d2||d1×d2|

Similarly, we can find the value of t2 by crossing with d1 and work from there to find the value of t2.

t2=|(p2p1)×d1||d1×d2|

The proof can be found here .


We can actually solve this problem graphically by using triangle similarity . Imagine the following situation:

line line intersection

line line intersection

The intersection point p is equal to:

(1)p=a+|pa|ba^=a+|pa|ba|ba|

By triangle similarity, we see that:

|pa||ba|=|na||ma|

Multiplying the left side with an identity

(2)|pa||ba|=|na||ma||dc||dc|

We see that the quantity |na||dc| is equal to the area of a parallelogram. We can skew the parallelogram (in the graphic, towards the x-axis) so that the left side becomes ca and the bottom side dc (which is not affected by the skew). Note that the area can also be expressed with the cross product of the vectors ca and dc. Therefore,

(3)|na||dc|=|(ca)×(dc)|

A similar equation can be derived for the parallelogram with sides ma and dc, only this time the skewed side will become ba

(4)|ma||dc|=|(ba)×(dc)|

Replacing (3) and (4) in (2) and (1), we see that the intersection point is equal to:

p=a+(ba)|(ca)×(dc)||(ba)×(dc)|