Line-line intersection

Given two lines in 3D defined as rays

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

Where t1,t2∈R, 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=|(p2βˆ’p1)Γ—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=|(p2βˆ’p1)Γ—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+|pβˆ’a|bβˆ’a^=a+|pβˆ’a|bβˆ’a|bβˆ’a|

By triangle similarity we see that

|pβˆ’a||bβˆ’a|=|nβˆ’a||mβˆ’a|

Multiplying the left side with an identity

(2)|pβˆ’a||bβˆ’a|=|nβˆ’a||mβˆ’a||dβˆ’c||dβˆ’c|

We see that the quantity |nβˆ’a||dβˆ’c| is equal to the equation of the area of a parallelogram, we can skew the parallelogram (in the graphic towards the x-axis) so that the left side becomes cβˆ’a and the bottom side dβˆ’c (which is not affected by the skew), note that the area can also be expressed with the cross product of the vectors cβˆ’a and dβˆ’c therefore

(3)|nβˆ’a||dβˆ’c|=|(cβˆ’a)Γ—(dβˆ’c)|

A similar equation can be derived for the parallelogram with sides mβˆ’a and dβˆ’c, only this time the skewed side will become bβˆ’a

(4)|mβˆ’a||dβˆ’c|=|(bβˆ’a)Γ—(dβˆ’c)|

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

p=a+(bβˆ’a)|(cβˆ’a)Γ—(dβˆ’c)||(bβˆ’a)Γ—(dβˆ’c)|