Distance From Point To Line

From CGAFaq

Jump to: navigation, search

The distance between a point C and a line L is the distance from C to the nearest point N on L. The nearest point is given by the fact that the line between N and C must be perpendicular to L. Thus:

Let the line L be parametrized by

where
is a point on the line
is a vector denoting the direction of the line

The condition for perpendicularity is

Using the properties of the dot product yields





The division can be avoided by choosing D a unit vector.

The distance between C and L is then given by:

Personal tools