|
|
The ray is parameterized as X = P + t * D where P is a point on the ray, t >= 0 and D is the ray direction. Given a point Q we want to find the closest distance of Q to the ray X. The closest point on the ray to Q is the projection of Q onto the ray, or in other words Qproj = P + u * D where u = (D * (Q - P)) / (D * D) if u > 0. If u <= 0 however the closest point to Q on the ray is P. The distance from Q to the ray is therefore: d = |Q - P| if u <= 0 d = |Q - Qproj| = |Q - (P + u * D)| if u > 0
|
Copyright © by Martin Ecker |