MICE_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
positn the array(s) defining the Cartesian position of a point with
respect to the center of an ellipsoid. The vector is expressed
in a body-fixed reference frame. The semi-axes of the
ellipsoid are aligned with the x, y, and z-axes of the
[3,n] = size(rectan); double = class(rectan)
a, values of the ellipsoid's triaxial radii ellipsoid, where:
'a' is length in kilometers of the semi-axis of the
ellipsoid parallel to the x-axis of the body-fixed
[1,1] = size(a); double = class(a)
'b' is length in kilometers of the semi-axis of the
ellipsoid parallel to the y-axis of the body-fixed
[1,1] = size(b); double = class(b)
'c' is length in kilometers of the semi-axis of the
ellipsoid parallel to the z-axis of the body-fixed
[1,1] = size(c); double = class(c)
[ npoint ] = mice_nearpt( positn, a, b, c )
npoint the structure(s) containing the results of the calculation.
[1,n] = size(npoint); struct = class(npoint)
Each structure consists of the fields:
'pos' the double precision 3-vector defining the location
in the body-fixed frame on the ellipsoid closest
[3,1] = size(npoint(i).pos); double = class(npoint(i).pos)
'alt' the double precision scalar altitude of 'positn'
above the ellipsoid. If 'positn' is inside the
ellipsoid, 'alt' will be negative and have magnitude
equal to the distance between 'pos' and 'positn'
[1,1] = size(npoint(i).alt); double = class(npoint(i).alt)
'npoint' returns with the same vectorization measure, N, as 'positn'.
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.
% Define the radii of an ellipsoid.
a = 1.;
b = 2.;
c = 3.;
% Use point on the X axis, outside the ellipsoid.
point = [ 3.5; 0.; 0. ];
pnear = mice_nearpt( point, a, b, c);
% Load a meta kernel containing SPK and leapseconds kernels.
% 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.;
abcorr = 'LT+S';
loc = mice_spkpos( 'moon', epoch, 'IAU_EARTH', abcorr, 'earth' );
% Retrieve the triaxial radii for Earth (body ID 399).
radii = cspice_bodvrd( 'EARTH', 'RADII', 3);
% Now calculate the point on the Earth nearest to the Moon
% given LT+S aberration correction at the epoch time.
npoint = mice_nearpt( loc.pos, radii(1), radii(2), radii(3) );
A sister version of this routine exists named cspice_nearpt that returns
the structure field data as separate arguments.
For important details concerning this module's function, please refer to
the CSPICE routine nearpt_c.
-Mice Version 1.0.1, 03-DEC-2014, EDW (JPL)
Edited I/O section to conform to NAIF standard for Mice documentation.
-Mice Version 1.0.0, 21-DEC-2005, EDW (JPL)
distance from point to ellipsoid
nearest point on an ellipsoid