void pltnp_c ( ConstSpiceDouble point[3],
ConstSpiceDouble v1 [3],
ConstSpiceDouble v2 [3],
ConstSpiceDouble v3 [3],
SpiceDouble pnear[3],
SpiceDouble * dist )
Find the nearest point on a triangular plate to a given point.
None.
GEOMETRY
MATH
Variable I/O Description
-------- --- --------------------------------------------------
point I A point in 3-dimensional space.
v1,
v2,
v3 I Vertices of a triangular plate.
pnear O Nearest point on the plate to `point'.
dist O Distance between `pnear' and `point'.
point is an arbitrary point in 3-dimensional space.
v1,
v2,
v3 are 3-vectors constituting the vertices of
a triangular plate.
The plate is allowed to be degenerate: it may
consist of a line segment or of a single point.
pnear is the closest point on the plate to `point'.
`pnear' is unique, since the plate is convex.
dist is the distance between `point' and `pnear'.
None.
1) The input plate is allowed to be degenerate: it may be
a line segment or a single point.
None.
None.
The numerical results shown for these examples may differ across
platforms. The results depend on the SPICE kernels used as input
(if any), the compiler and supporting libraries, and the machine
specific arithmetic implementation.
1) Find the nearest point to the point (2,2,2) on a plate having
vertices at the unit basis vectors that lie along the positive
X, Y, and Z coordinate axes.
Example code begins here.
#include <stdio.h>
#include "SpiceUsr.h"
int main()
{
/.
Local variables
./
SpiceDouble dist;
SpiceDouble pnear[3];
SpiceDouble point[3] = {2.0, 2.0, 2.0};
SpiceDouble v1 [3] = {1.0, 0.0, 0.0};
SpiceDouble v2 [3] = {0.0, 1.0, 0.0};
SpiceDouble v3 [3] = {0.0, 0.0, 1.0};
pltnp_c ( point, v1, v2, v3, pnear, &dist );
printf ( "\n"
"Plate vertex 1 = %14.7e %14.7e %14.7e\n"
"Plate vertex 2 = %14.7e %14.7e %14.7e\n"
"Plate vertex 3 = %14.7e %14.7e %14.7e\n"
"Input point = %14.7e %14.7e %14.7e\n"
"\n"
"Near point = %14.7e %14.7e %14.7e\n"
"Distance = %14.7e\n"
"\n",
v1[0], v1[1], v1[2],
v2[0], v2[1], v2[2],
v3[0], v3[1], v3[2],
point[0], point[1], point[2],
pnear[0], pnear[1], pnear[2],
dist );
return ( 0 );
}
When this program was executed on a PC/Linux/gcc/64-bit platform,
the output was:
Plate vertex 1 = 1.0000000e+00 0.0000000e+00 0.0000000e+00
Plate vertex 2 = 0.0000000e+00 1.0000000e+00 0.0000000e+00
Plate vertex 3 = 0.0000000e+00 0.0000000e+00 1.0000000e+00
Input point = 2.0000000e+00 2.0000000e+00 2.0000000e+00
Near point = 3.3333333e-01 3.3333333e-01 3.3333333e-01
Distance = 2.8867513e+00
None.
None.
N.J. Bachman (JPL)
-CSPICE Version 1.0.0, 1-FEB-2016 (NJB)
nearest point on triangular plate
Link to routine pltnp_c source file pltnp_c.c
|