Index Page pltnp_c

A B C D E F G H I J K L M N O P Q R S T U V W X

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[3],
                      ConstSpiceDouble    v1   [3],
                      ConstSpiceDouble    v2   [3],
                      ConstSpiceDouble    v3   [3],
                      SpiceDouble         pnear[3],
                      SpiceDouble       * dist      )

#### Abstract

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

#### Required_Reading

       None.

#### Keywords

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

#### Parameters

       None.

#### Exceptions

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

#### Files

       None.

#### Particulars

       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[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

#### Restrictions

       None.

#### Literature_References

       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

#### Link to routine pltnp_c source file pltnp_c.c

    Wed Apr  5 17:54:40 2017