CSPICE_NPLNPT calculates the location on a defined line
nearest to a specified point, then determines the distance
between the two points.
Given:
linpt [3,1] = size(linpt); double = class(linpt)
lindir [3,1] = size(lindir); double = class(lindir)
are, respectively, a point and a direction vector that define
a line. The line is the set of vectors
linept + t * linedr
where t is any real number.
point a point in 3dimensional space.
[3,n] = size(point); double = class(point)
the call:
[ pnear, dist ] = cspice_nplnpt( linpt, lindir, point )
returns:
pnear the nearest point on the input line to the input 'point'.
[3,1] = size(pnear); double = class(pnear)
dist distance between the input line and input point.
[1,n] = size(dist); double = class(dist)
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
%
% Define a point on a line, a direction for the line, and
% an arbitrary point in space.
%
linept = [ 1, 2, 3 ]';
linedr = [ 0, 1, 1 ]';
point = [ 6, 9, 10 ]';
%
% Calculate the location on the line nearest the point
% and the distance between the location and the defined
% point.
%
[ pnear, dist ] = cspice_nplnpt( linept, linedr, point )
MATLAB outputs:
pnear =
1
9
10
dist =
7
For every line L and point P, there is a unique closest point
on L to P. Call this closest point C. It is always true that
P  C is perpendicular to L, and the length of P  C is called
the "distance" between P and L.
For important details concerning this module's function, please refer to
the CSPICE routine nplnpt_c.
MICE.REQ
Mice Version 1.0.0, 14NOV2013, EDW (JPL), SCK (JPL)
distance between point and line
nearest point on line to point
