Intuitlvely, given a point o and a line L≡p+αx (greek letters will be reals, all else vectors), we must have that the line that witnesses the shortest distance from o to L must be perpendicular to L.
For if not, we would have some "slack" that we could spend to shorten the distance. Alternatively, using Lagrange multipliers intuition, the gradient must be perpendicular to the level surface of the constraint. In this case, we are tryng to find a point o′ that minimizes distance oo′ such that o′∈L. The ladder is a lagrange constraint, and hence defines a level surface to which the optimal solution must be perpendicular to.
Some calculus to prove this Let l≡p+αx be a point on the line L. We extrmize the length olas a parameter of α:
∂α(ol⋅ol)=0∂α((o−p−αx)⋅(o−p−αx)=0only terms with α survive ∂α: ∂α−o⋅αx+p⋅αx−αx⋅o−αx⋅(−p)−αx⋅(−αx)=0∂α−2αo⋅x+2p⋅αx+α2x⋅x=0∂α−2αo⋅x+2αp⋅x+α2x⋅x=0−2o⋅x+2p⋅x+2αx⋅x=02(−o+p+αx)⋅x=02(−o+l)⋅x=02(lo)⋅x=0(lo)⋅x=0lo⊥x
This tells us that the line ol is perpendicular to the direction x, which is the direction of the line L. Hence, the line (ol) from the point o to the line L with minimum distance is orthogonal to the line L itself.
We can take two parametric points on two lines L≡p+αx, and M≡q+βy, and build the line lm which witnesses the shortest distance.
From the above derivation, we see that the line lm must be perpendicular to both L and M, since we can view line-line-distance as two simultaneous point-line-distance problems: distance from point l∈L to line M, and distance from point m∈M to line L.
This gives us the equations lm⋅x=0, and lm⋅y=0. We have two variables α,β and two equations, so we solve for α,beta.
This allows us to find the line lm whose length is the shortest distance.