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_sphlat

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


Abstract


   CSPICE_SPHLAT converts spherical coordinates to latitudinal
   coordinates.

I/O


   Given:

      r        the distance of the point from the origin.

               help, r
                  DOUBLE = Scalar

      colat    the angle between the vector from the origin to the point and
               the positive Z-axis in radians.

               help, colat
                  DOUBLE = Scalar

      slon     the angle of the point from the XZ plane (radians).

               help, slon
                  DOUBLE = Scalar

   the call:

      cspice_sphlat, r, colat, slon, radius, lon, lat

   returns:

      radius   the distance of a point from the origin.

               help, radius
                  DOUBLE = Scalar

      lon      the angle of the point from the XZ plane in radians.

               help, lon
                  DOUBLE = Scalar

               `lon' is set equal to `slon'.

      lat      the angle of the point from the XY plane in radians.

               help, lat
                  DOUBLE = Scalar

               `lat' is computed as pi/2 - colat.

Parameters


   None.

Examples


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

   1) Latitude is obtained by subtracting co-latitude from cspice_halfpi
      Radius and longitude mean the same thing in both latitudinal
      and spherical coordinates. The table below lists `lat' and
      corresponding `colat' in terms of degrees.

           lat     colat
          -----    -----
             0        90
            20        70
            45        45
           -30       120
            90         0
           -45       135


   2) Compute the spherical coordinates of the position of the Moon
      as seen from the Earth, and convert them to latitudinal and
      rectangular coordinates.

      Use the meta-kernel shown below to load the required SPICE
      kernels.


         KPL/MK

         File name: sphlat_ex2.tm

         This meta-kernel is intended to support operation of SPICE
         example programs. The kernels shown here should not be
         assumed to contain adequate or correct versions of data
         required by SPICE-based user applications.

         In order for an application to use this meta-kernel, the
         kernels referenced here must be present in the user's
         current working directory.

         The names and contents of the kernels referenced
         by this meta-kernel are as follows:

            File name                     Contents
            ---------                     --------
            de421.bsp                     Planetary ephemeris
            naif0012.tls                  Leapseconds


         \begindata

            KERNELS_TO_LOAD = ( 'de421.bsp',
                                'naif0012.tls'  )

         \begintext

         End of meta-kernel


      Example code begins here.


      PRO sphlat_ex2

         ;;
         ;; Load SPK and LSK kernels, use a meta kernel for
         ;; convenience.
         ;;
         cspice_furnsh, 'sphlat_ex2.tm'

         ;;
         ;; Look up the geometric state of the Moon as seen from
         ;; the Earth at 2017 Mar 20, relative to the J2000
         ;; reference frame.
         ;;
         cspice_str2et, '2017 Mar 20', et

         cspice_spkpos, 'Moon', et, 'J2000', 'NONE', 'Earth', pos, ltime

         ;;
         ;; Convert the position vector `pos' to spherical
         ;; coordinates.
         ;;
         cspice_recsph, pos, r, colat, slon

         ;;
         ;; Convert the spherical coordinates to latitudinal.
         ;;
         cspice_sphlat, r, colat, slon, radius, lon, lat

         ;;
         ;; Convert the latitudinal coordinates to rectangular.
         ;;
         cspice_latrec, radius, lon, lat, rectan

         print, ' '
         print, 'Original rectangular coordinates:'
         print, ' '
         print, format='(A,F20.8)', ' X           (km): ', pos[0]
         print, format='(A,F20.8)', ' Y           (km): ', pos[1]
         print, format='(A,F20.8)', ' Z           (km): ', pos[2]
         print, ' '
         print, 'Spherical coordinates:'
         print, ' '
         print, format='(A,F20.8)', ' Radius      (km): ', r
         print, format='(A,F20.8)', ' Colatitude (deg): ',                   $
                                    colat*cspice_dpr( )
         print, format='(A,F20.8)', ' Longitude  (deg): ',                   $
                                    slon*cspice_dpr( )
         print, ' '
         print, 'Latitudinal coordinates:'
         print, ' '
         print, format='(A,F20.8)', ' Radius      (km): ', radius
         print, format='(A,F20.8)', ' Longitude  (deg): ', lon*cspice_dpr( )
         print, format='(A,F20.8)', ' Latitude   (deg): ', lat*cspice_dpr( )
         print, ' '
         print, 'Rectangular coordinates from cspice_latrec:'
         print, ' '
         print, format='(A,F20.8)', ' X           (km): ', rectan[0]
         print, format='(A,F20.8)', ' Y           (km): ', rectan[1]
         print, format='(A,F20.8)', ' Z           (km): ', rectan[2]
         print, ' '

      END


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


      Original rectangular coordinates:

       X           (km):      -55658.44323296
       Y           (km):     -379226.32931475
       Z           (km):     -126505.93063865

      Spherical coordinates:

       Radius      (km):      403626.33912495
       Colatitude (deg):         108.26566077
       Longitude  (deg):         -98.34959789

      Latitudinal coordinates:

       Radius      (km):      403626.33912495
       Longitude  (deg):         -98.34959789
       Latitude   (deg):         -18.26566077

      Rectangular coordinates from cspice_latrec:

       X           (km):      -55658.44323296
       Y           (km):     -379226.32931475
       Z           (km):     -126505.93063865


   3) Create a table showing a variety of spherical coordinates
      and the corresponding cylindrical coordinates.

      Corresponding spherical and cylindrical coordinates are
      listed to three decimal places. Input and output angles
      are in degrees.


      Example code begins here.


      PRO sphlat_ex3

         ;;
         ;; Local parameters.
         ;;
         NREC = 11

         ;;
         ;; Define the input spherical coordinates. Angles in
         ;; degrees.
         ;;
         r      = [  0.0d,  1.0d,   1.0d,    1.0d,   1.4142d,  1.0d,         $
                     1.0d,  1.0d,   1.4142d, 1.0d,   0.0d           ]

         colat  = [  0.0d, 90.0d,  90.0d,    0.0d,  45.0d,    90.0d,         $
                   180.0d, 90.0d, 135.0d,    0.0d,  90.0d           ]

         slon   = [  0.0d,  0.0d,  90.0d,    0.0d, 180.0d,   -90.0d,         $
                     0.0d, 45.0d, 180.0d,  180.0d,  33.0d           ]

         ;;
         ;; Print the banner.
         ;;
         print, '     r      colat     slon    radius    lon      lat'
         print, '  -------  -------  -------  -------  -------  -------'

         ;;
         ;; Do the conversion. Output angles in degrees.
         ;;
         for i=0, NREC - 1L do begin

            rcolat = colat[i] * cspice_rpd( )
            rslon  = slon[i]  * cspice_rpd( )

            cspice_sphlat, r[i], rcolat, rslon, radius, lon, lat

            print, format='(3F9.3,$)', r[i], colat[i], slon[i]
            print, format='(3F9.3)', radius, lon * cspice_dpr(),             $
                                             lat * cspice_dpr()

         endfor

      END


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


           r      colat     slon    radius    lon      lat
        -------  -------  -------  -------  -------  -------
          0.000    0.000    0.000    0.000    0.000   90.000
          1.000   90.000    0.000    1.000    0.000    0.000
          1.000   90.000   90.000    1.000   90.000    0.000
          1.000    0.000    0.000    1.000    0.000   90.000
          1.414   45.000  180.000    1.414  180.000   45.000
          1.000   90.000  -90.000    1.000  -90.000    0.000
          1.000  180.000    0.000    1.000    0.000  -90.000
          1.000   90.000   45.000    1.000   45.000    0.000
          1.414  135.000  180.000    1.414  180.000  -45.000
          1.000    0.000  180.000    1.000  180.000   90.000
          0.000   90.000   33.000    0.000   33.000    0.000


Particulars


   This routine returns the latitudinal coordinates of a point
   whose position is input in spherical coordinates.

   Latitudinal coordinates are defined by a distance from a central
   reference point, an angle from a reference meridian, and an angle
   above the equator of a sphere centered at the central reference
   point.

   Spherical coordinates are defined by a distance from a central
   reference point, an angle from a reference meridian, and an angle
   from the Z-axis.

Exceptions


   1)  If any of the input arguments, `r', `colat' or `slon', is
       undefined, an error is signaled by the IDL error handling
       system.

   2)  If any of the input arguments, `r', `colat' or `slon', is not
       of the expected type, or it does not have the expected
       dimensions and size, an error is signaled by the Icy
       interface.

   3)  If any of the output arguments, `radius', `lon' or `lat', is
       not a named variable, an error is signaled by the Icy
       interface.

Files


   None.

Restrictions


   None.

Required_Reading


   ICY.REQ

Literature_References


   None.

Author_and_Institution


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

Version


   -Icy Version 1.1.0, 10-AUG-2021 (JDR)

       Edited the header to comply with NAIF standard. Added complete code
       examples.

       Changed the input argument name "lons" to "slon" for consistency
       with other routines.

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

       Removed reference to the routine's corresponding CSPICE header from
       -Abstract section.

       Added arguments' type and size information in the -I/O section.

   -Icy Version 1.0.1, 09-DEC-2005 (EDW)

       Added -Examples section.

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

Index_Entries


   spherical to latitudinal coordinates



Fri Dec 31 18:43:07 2021