Table of contents
CSPICE_NPLNPT calculates the location on a defined line
nearest to a specified point, then determines the distance
between the two points.
Given:
linpt,
lindir respectively, a point and a direction vector that define a line
in 3-dimensional space.
help, linpt
DOUBLE = Array[3]
help, lindir
DOUBLE = Array[3]
The line is the set of points
linpt + t * lindir
where `t' is any real number.
point a point in 3-dimensional space.
help, point
DOUBLE = Array[3]
the call:
cspice_nplnpt, linpt, lindir, point, pnear, dist
returns:
pnear the nearest point on the input line to the input point.
help, pnear
DOUBLE = Array[3]
dist the distance between the input line and input point.
help, dist
DOUBLE = Scalar
None.
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.
1) Define a line, given a point and a direction for the line, and an
arbitrary point in space, and calculate the location on the line
nearest to the arbitrary point, and the distance between these two
points.
Example code begins here.
PRO nplnpt_ex1
;;
;; Define a point on a line, a direction for the line, and
;; an arbitrary point in space.
;;
linept = [ 1.d, 2.d, 3.d ]
linedr = [ 0.d, 1.d, 1.d ]
point = [ -6.d, 9.d, 10.d ]
;;
;; Calculate the location on the line nearest the point
;; and the distance between the location and the defined
;; point.
;;
cspice_nplnpt, linept, linedr, point, pnear, dist
print, 'Nearest point: ', pnear
print, 'Distance : ', dist
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Nearest point: 1.0000000 9.0000000 10.000000
Distance : 7.0000000
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.
1) If the line direction vector `lindir' is the zero vector, the
error SPICE(ZEROVECTOR) is signaled by a routine in the call
tree of this routine.
2) If any of the input arguments, `linpt', `lindir' or `point',
is undefined, an error is signaled by the IDL error handling
system.
3) If any of the input arguments, `linpt', `lindir' or `point',
is not of the expected type, or it does not have the expected
dimensions and size, an error is signaled by the Icy
interface.
4) If any of the output arguments, `pnear' or `dist', is not a
named variable, an error is signaled by the Icy interface.
None.
None.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.2, 13-AUG-2021 (JDR)
Edited the header to comply with NAIF standard. Added example's
problem statement and reformatted example's output.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections.
Removed reference to the routine's corresponding CSPICE header from
-Abstract section.
Added arguments' type and size information in the -I/O section.
-Icy Version 1.0.1, 13-JUN-2011 (EDW)
Edits to -I/O and -Particulars sections so as to parallel Mice
version.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
distance between point and line
nearest point on line to point
|