pltnp_c |
Table of contents
Procedurepltnp_c ( Nearest point on triangular plate ) void pltnp_c ( ConstSpiceDouble point[3], ConstSpiceDouble v1 [3], ConstSpiceDouble v2 [3], ConstSpiceDouble v3 [3], SpiceDouble pnear[3], SpiceDouble * dist ) AbstractFind the nearest point on a triangular plate to a given point. Required_ReadingDSK KeywordsGEOMETRY MATH Brief_I/OVARIABLE 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_Inputpoint 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_Outputpnear 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'. ParametersNone. Exceptions1) The input plate is allowed to be degenerate: it may be a line segment or a single point. FilesNone. ParticularsNone. ExamplesThe numerical results shown for this example 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. /. Program pltnp_ex1 ./ #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 Mac/Intel/cc/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 RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) Version-CSPICE Version 1.0.1, 04-MAR-2019 (JDR) Edited the header to comply with NAIF standard. -CSPICE Version 1.0.0, 01-FEB-2016 (NJB) Index_Entriesnearest point on triangular plate |
Fri Dec 31 18:41:10 2021