pltnp_c

 Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input Detailed_Output Parameters Exceptions Files Particulars Examples Restrictions Literature_References Author_and_Institution Version Index_Entries

#### Procedure

```   void pltnp_c ( ConstSpiceDouble    point,
ConstSpiceDouble    v1   ,
ConstSpiceDouble    v2   ,
ConstSpiceDouble    v3   ,
SpiceDouble         pnear,
SpiceDouble       * dist      )
```

#### Abstract

```
Find the nearest point on a triangular plate to a given point.
```

```
None.
```

```
GEOMETRY
MATH

```

#### Brief_I/O

```
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'.
```

#### Detailed_Input

```
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.
```

#### Detailed_Output

```
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.
```

#### Exceptions

```
1) The input plate is allowed to be degenerate: it may be
a line segment or a single point.
```

```
None.
```

```
None.
```

#### Examples

```
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;
SpiceDouble             point = {2.0, 2.0, 2.0};
SpiceDouble             v1    = {1.0, 0.0, 0.0};
SpiceDouble             v2    = {0.0, 1.0, 0.0};
SpiceDouble             v3    = {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,    v1,    v1,
v2,    v2,    v2,
v3,    v3,    v3,
point, point, point,
pnear, pnear, pnear,
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.
```

#### Author_and_Institution

```
N.J. Bachman   (JPL)
```

#### Version

```
-CSPICE Version 1.0.0, 1-FEB-2016 (NJB)
```

#### Index_Entries

```
nearest point on triangular plate
```
`Wed Apr  5 17:54:40 2017`