pltnp |
Table of contents
ProcedurePLTNP ( Nearest point on triangular plate ) SUBROUTINE PLTNP ( POINT, V1, V2, V3, PNEAR, DIST ) AbstractFind the nearest point on a triangular plate to a given point. Required_ReadingDSK KeywordsGEOMETRY MATH DeclarationsIMPLICIT NONE DOUBLE PRECISION POINT ( 3 ) DOUBLE PRECISION V1 ( 3 ) DOUBLE PRECISION V2 ( 3 ) DOUBLE PRECISION V3 ( 3 ) DOUBLE PRECISION PNEAR ( 3 ) DOUBLE PRECISION DIST 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 IMPLICIT NONE C C Local parameters C CHARACTER*(*) FMT1 PARAMETER ( FMT1 = '(A,3E15.7)' ) C C Local variables C DOUBLE PRECISION DIST DOUBLE PRECISION POINT ( 3 ) DOUBLE PRECISION PNEAR ( 3 ) DOUBLE PRECISION V1 ( 3 ) DOUBLE PRECISION V2 ( 3 ) DOUBLE PRECISION V3 ( 3 ) C C POINT is the input point. C CALL VPACK ( 2.D0, 2.D0, 2.D0, POINT ) C C V1, V2, V3 are the vertices of a plate. C CALL VPACK ( 1.D0, 0.D0, 0.D0, V1 ) CALL VPACK ( 0.D0, 1.D0, 0.D0, V2 ) CALL VPACK ( 0.D0, 0.D0, 1.D0, V3 ) C C Find the near point on the plate. C CALL PLTNP ( POINT, V1, V2, V3, PNEAR, DIST ) WRITE (*,*) ' ' WRITE (*,FMT1) 'Plate vertex 1 = ', V1 WRITE (*,FMT1) 'Plate vertex 2 = ', V2 WRITE (*,FMT1) 'Plate vertex 3 = ', V3 WRITE (*,FMT1) 'Input point = ', POINT WRITE (*,*) ' ' WRITE (*,FMT1) 'Near point = ', PNEAR WRITE (*,FMT1) 'Distance = ', DIST WRITE (*,*) ' ' END When this program was executed on a Mac/Intel/gfortran/64-bit platform, the output was: Plate vertex 1 = 0.1000000E+01 0.0000000E+00 0.0000000E+00 Plate vertex 2 = 0.0000000E+00 0.1000000E+01 0.0000000E+00 Plate vertex 3 = 0.0000000E+00 0.0000000E+00 0.1000000E+01 Input point = 0.2000000E+01 0.2000000E+01 0.2000000E+01 Near point = 0.3333333E+00 0.3333333E+00 0.3333333E+00 Distance = 0.2886751E+01 RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) VersionSPICELIB Version 1.1.3, 04-JUL-2021 (JDR) Edited the header to comply with NAIF standard. Edited code example output format for the solution to fit within the $Examples section without modifications. Added DSK to $Required_Readings. SPICELIB Version 1.1.2, 01-FEB-2016 (NJB) Added code example to header. DSKLIB Version 1.1.1, 19-MAR-2015 (NJB) Fixed spelling error in header. DSKLIB Version 1.1.0, 31-DEC-2014 (NJB) Bug fix: vertex indices for outside case, near point on 3rd edge were corrected. DSKLIB Version 1.0.0, 29-SEP-2014 (NJB) |
Fri Dec 31 18:36:39 2021