cspice_nearpt

 Abstract I/O Examples Particulars Required Reading Version Index_Entries
```
```

#### Abstract

```
CSPICE_NEARPT calculates the point on the surface of an
ellipsoid nearest to a specified off-ellipsoid position.
The routine also returns the altitude of the position
above the ellipsoid.

For important details concerning this module's function, please refer to
the CSPICE routine nearpt_c.

```

#### I/O

```
Given:

positn   a double precision position 3-vector of Cartesian
coordinates in the body fixed frame of an ellipsoid

a,       the scalar double precision values of the ellipsoid's
c
'a' is length in kilometers of the semi-axis of the ellipsoid
parallel to the x-axis of the body-fixed reference frame

'b' is length in kilometers of the semi-axis of the ellipsoid
parallel to the y-axis of the body-fixed reference frame

'c' is length in kilometers of the semi-axis of the ellipsoid
parallel to the z-axis of the body-fixed reference frame

the call:

cspice_nearpt, positn, a, b, c, npoint, alt

returns:

npoint   the double precision 3-vector defining the location
on the ellipsoid closest to 'positn'

alt      the double precision scalar altitude of 'positn'
above the ellipsoid. If 'positn' is inside the ellipsoid, '
alt' has negative value and have magnitude equal to the
distance between 'npoint' and 'positn'.

```

#### Examples

```
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.

Example(1):

;;
;; Define the radii of an ellipsoid.
;;
a  =  1.d
b  =  2.d
c  =  3.d

;;
;; Use point on the X axis, outside the ellipsoid.
;;
point  = [ 3.5d, 0.d, 0.d ]
cspice_nearpt, point, a, b, c, pnear, alt

print, pnear
print, alt

IDL outputs for pnear:    1.0000000   0.0000000   0.0000000
IDL outputs for alt  :    2.5000000

Example(2):

;;
;; Load a meta kernel containing SPK and leapseconds kernels.
;;
cspice_furnsh, 'standard.tm'

;;
;; Retrieve the position of the Moon wrt the Earth at
;; ephemeris time 0.d (Jan 1 2000 12:00 TDB) in the Earth-fixed
;; reference frame.
;;
epoch = 0.d
abcorr= 'LT+S'
cspice_spkezr, 'moon', epoch, 'IAU_EARTH', abcorr, 'earth', \$
state, ltime

;;
;; Retrieve the triaxial radii for Earth (body ID 399).
;;

;;
;; Now calculate the point on the Earth nearest to the Moon
;; given LT+S aberration correction at the epoch time.
;;
print, npoint
print, alt

IDL outputs for npoint:
3345.8825  -5295.2982  -1198.2813

IDL outputs for alt:
396037.22

```

```
None.

```

```
ICY.REQ
ELLIPSES.REQ

```

#### Version

```
-Icy Version 1.0.1, 16-DEC-2005, EDW (JPL)

Edits to 'alt' description in I/O section.

-Icy Version 1.0.0, 16-JUN-2003, EDW (JPL)

```

#### Index_Entries

```
distance from point to ellipsoid
nearest point on an ellipsoid

```
`Wed Apr  5 17:58:02 2017`