|
|
The line is parameterized as X = P + t * D where P is a point on the line, t is a real value and D is the line direction which is not necessarily unit-length. Given a point Q we want to find the closest distance of Q to the line X. The closest point on the line to Q is the projection of Q onto the line, or in other words Qproj = P + u * D where u = (D * (Q - P)) / (D * D) The distance from Q to the line is therefore: d = |Q - Qproj| = |Q - (P + u * D)|
|
Copyright © by Martin Ecker |