The intersection of two co-planar lines

If two lines in space intersect, the intersection point may be found using the technique described here. The figure may help clarify the discussion.

Assume each line is defined by two points on the line. In the figure the lines are shown in blue and the defining points in green. Blue vectors are shown between the points.

The desired intersection point is labeled I and shown in red.

Note the two similar triangles that touch at point I. Corresponding sides of the triangles are H and h, and P and p. If either pair of sides is known point I is easily found as the fractional distance H/(H+h) from point A to point B. This is the same as P/(P+p).

The perpendicular distances of points A and B, P and p, from line CD will be found. The values must be signed distances since in general the intersection point need not be between A and B.

A unit vector, U3, perpendicular to line AB and pointing toward point A will be found. Then vectors V and W will be dotted with U3, giving P and p, both signed quantities.

Algorithm

In IDL:
  U1 = unit(B-A)
  U2 = unit(D-C)
  V = A - C
  W = B - C
  U3 = unit(V - total(V*U2)*U2)
  P1 = total(V*U3)
  P2 = total(W*U3)
  FRAC = (P1/(P1+P2))
  I = A + sign(FRAC)*U1*FRAC


Terms