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

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries

Abstract


   CSPICE_NPELPT finds the nearest point on an ellipse to a specified point,
   both in three-dimensional space, and finds the distance between the
   ellipse and the point.

I/O


   Given:

      point    a point in 3-dimensional space.

               [3,1] = size(point); double = class(point)

      ellips   a SPICE ellipse that represents an ellipse in
               three-dimensional space.

               [1,1] = size(ellips); struct = class(ellips)

               The structure has the fields:

                 center:    [3,1] = size(center); double = class(center)
                 semiMinor: [3,1] = size(semiMinor); double =
                 class(semiMinor) semiMajor: [3,1] = size(semiMajor); double
                 = class(semiMajor)

   the call:

      [pnear, dist] = cspice_npelpt( point, ellips )

   returns:

      pnear    the nearest point on `ellips' to `point'.

               [3,1] = size(pnear); double = class(pnear)

      dist     the distance between `point' and `pnear'.

               [1,1] = size(dist); double = class(dist)

               This is the distance between `point' and the ellipse.

Parameters


   None.

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.

   1) Create a SPICE ellipse given its center and its semi-major and
      semi-minor axes, and calculate the location on that ellipse
      which is closest to a defined point, and the distance between
      those points.

      Example code begins here.


      function npelpt_ex1()

         %
         % Define a center, and semimajor and semiminor axes for
         % an ellipse.
         %
         % Also define an arbitrary point in space.
         %
         center = [  1.;  2.; -3. ];
         smajor = [  3.;  0.;  0. ];
         sminor = [  0.;  2.;  0. ];
         point  = [ -4.;  2.;  1. ];

         %
         % Create an ellipse structure using `center', `smajor',
         % and `sminor'.
         %
         ellips = cspice_cgv2el( center, smajor, sminor );

         fprintf( 'Input SPICE ellipse:\n' );
         fprintf( '  Semi-minor axis: %10.6f %10.6f %10.6f\n',   ...
                                              ellips.semiMinor);
         fprintf( '  Semi-major axis: %10.6f %10.6f %10.6f\n',   ...
                                              ellips.semiMajor);
         fprintf( '  Center         : %10.6f %10.6f %10.6f\n\n',   ...
                                              ellips.center   );

         %
         % Calculate the location on the ellipse closest to
         % the defined point.
         %
         [pnear, dist] = cspice_npelpt( point, ellips );
         fprintf( 'Nearest point    : %10.6f %10.6f %10.6f\n', pnear )
         fprintf( 'Distance         : %10.6f\n', dist                )


      When this program was executed on a Mac/Intel/Octave6.x/64-bit
      platform, the output was:


      Input SPICE ellipse:
        Semi-minor axis:   0.000000   2.000000   0.000000
        Semi-major axis:   3.000000   0.000000   0.000000
        Center         :   1.000000   2.000000  -3.000000

      Nearest point    :  -2.000000   2.000000  -3.000000
      Distance         :   4.472136


Particulars


   Given an ellipse and a point in 3-dimensional space, if the
   orthogonal projection of the point onto the plane of the ellipse
   is on or outside of the ellipse, then there is a unique point on
   the ellipse closest to the original point. This routine finds
   that nearest point on the ellipse. If the projection falls inside
   the ellipse, there may be multiple points on the ellipse that are
   at the minimum distance from the original point. In this case,
   one such closest point will be returned.

   This routine returns a distance, rather than an altitude, in
   contrast to the Mice routine cspice_nearpt. Because our ellipse is
   situated in 3-space and not 2-space, the input point is not
   "inside" or "outside" the ellipse, so the notion of altitude does
   not apply to the problem solved by this routine. In the case of
   cspice_nearpt, the input point is on, inside, or outside the ellipsoid,
   so it makes sense to speak of its altitude.

Exceptions


   1)  If the input ellipse `ellips' has one or both semi-axis lengths
       equal to zero, the error SPICE(DEGENERATECASE) is signaled by
       a routine in the call tree of this routine.

   2)  If the geometric ellipse represented by `ellips' does not
       have a unique point nearest to the input point, any point
       at which the minimum distance is attained may be returned
       in `pnear'.

   3)  If a ratio of non-zero ellipse radii violates the constraints
       imposed by cspice_nearpt, an error is signaled by a routine in the
       call tree of this routine.

   4)  The routine does not check for overflow when scaling or
       translating the input point.

   5)  If any of the input arguments, `point' or `ellips', is
       undefined, an error is signaled by the Matlab error handling
       system.

   6)  If any of the input arguments, `point' or `ellips', is not of
       the expected type, or it does not have the expected dimensions
       and size, an error is signaled by the Mice interface.

Files


   None.

Restrictions


   None.

Required_Reading


   ELLIPSES.REQ
   MICE.REQ

Literature_References


   None.

Author_and_Institution


   J. Diaz del Rio     (ODC Space)
   E.D. Wright         (JPL)

Version


   -Mice Version 1.1.0, 27-AUG-2021 (EDW) (JDR)

       Changed input argument name "ellipse" to "ellips".

       Edited the header to comply with NAIF standard. Added
       code example to -Examples section.

       Added -Parameters, -Exceptions, -Files, -Restrictions,
       -Literature_References and -Author_and_Institution sections.

       Eliminated use of "lasterror" in rethrow.

       Removed reference to the function's corresponding CSPICE header from
       -Required_Reading section.

   -Mice Version 1.0.0, 14-NOV-2014 (EDW)

Index_Entries


   nearest point on ellipse to point


Fri Dec 31 18:44:26 2021