The PNT_LINE function computes the perpendicular distance between a point P0 and a line between points L0 and L1. This function is limited by the machine accuracy of single precision floating point.
This routine is written in the IDL language. Its source code can be found in the file
pnt_line.pro in the
lib subdirectory of the IDL distribution.
Result = PNT_LINE( P0, L0, L1 [, Pl] [, /INTERVAL] )
Returns the perpendicular distance.
The location of the point. P0 may have 2 to n elements, for n dimensions.
One end-point of the line. L0 must have same number of elements as P0.
The other end-point of the line. L1 must have the same number of elements as L0.
A named variable that will contain the location of the point on the line between L0 and L1 that is closest to P0. Pl is not necessarily in the interval (L0, L1).
If set, and if the point on the line between L0 and L1 that is closest to P0 is not within the interval (L0, L1), PNT_LINE will return the distance from P0 to the closer of the two endpoints L0 and L1.
To print the distance between the point (2,3) and the line from (-3,3) to (5,12), and also the location of the point on the line closest to (2,3), enter the following command:
PRINT, PNT_LINE([2,3], [-3,3], [5,12], Pl), Pl
3.73705 -0.793104 5.48276
Introduced: Pre 4.0