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

Abstract
I/O
Examples
Particulars
Required Reading
Version
Index_Entries

Abstract


   CSPICE_CYLSPH converts cylindrical coordinates to spherical
   coordinates.

I/O


   Given:

      r      the value(s) describing the distance of the point of
             interest from z axis.

             [1,n] = size(r); double = class(r)

      lonc   the value(s) describing the cylindrical angle of the point of
             interest from the XZ plane measured in radians.

             [1,n] = size(lonc); double = class(lonc)

      z      the value(s) describing the height of the point above
             the XY plane.

             [1,n] = size(z); double = class(z)

   the call:

      [radius, colat, lon] = cspice_cylsph( r, lonc, z)

   returns:

      radius   the value(s) describing the distance of the position
               from the origin.

               [1,n] = size(radius); double = class(radius)

      colat    the value(s) describing the angle between the point and the
               positive z-axis, measured in radians (also referred to
               as the polar angle).

               [1,n] = size(colat); double = class(colat)

      lon      the value(s) describing the angle of the projection of the
               point to the XY plane from the positive X-axis, measured
               in radians, with range:

                   -pi < lon <= pi

               The positive Y-axis is at longitude PI/2 radians.

               [1,n] = size(lon); double = class(lon)

               The argument 'radius' returns in the same units associated
               with 'r' and 'z'.

               'radius', 'colat', and 'lon' return with the vectorization
               measure (N) as 'r', 'lonc', and 'z'.

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):

      %
      % Load an SPK, leapseconds, and PCK kernel set.
      %
      cspice_furnsh( 'standard.tm' )

      %
      % Create a vector of scalar times.
      %
      et = [0:2]*2.*cspice_spd;

      %
      % Retrieve the position of the moon seen from earth at 'et'
      % in the J2000 frame without aberration correction.
      %
      [pos, et] = cspice_spkpos( 'MOON', et, 'J2000', 'NONE', 'EARTH' );

      %
      % Convert the array of position vectors 'pos' to cylindrical
      % coordinates.
      %
      [r, lon, z] = cspice_reccyl(pos);

      %
      % Convert the cylindrical coords to spherical.
      %
      [radius, colat, lon] = cspice_cylsph(r, lon, z);

      %
      % Convert the spherical to rectangular.
      %
      [rectan] = cspice_sphrec(radius, colat, lon);

      %
      % Calculate the relative error against the original position
      % vectors.
      %
      (rectan-pos) ./ pos

   MATLAB outputs:

      1.0e-13 *

      0.00199609007208   0.00185077353361  -0.25349834013312
     -0.00436475351630                  0  -0.00153127196389
     -0.00382429455002  -0.00485521702846   0.00203951344664

      The relative error between the original array of position vectors
      and those resulting from the coordinate conversions
      has magnitude on the order of 10^(-13).

   Example (2):

      %
      % Define six sets of cylindrical coordinates, 'lonc' expressed
      % in degrees - converted to radians by use of cspice_rpd.
      %
      r     = [ 1.,  1.,   1.,   1.,   0.,  0. ];
      lonc  = [ 0., 90., 180., 180., 180., 33. ] * cspice_rpd;
      z     = [ 0.,  0.,   1.,  -1.,   1.,  0. ];

      %
      % ...convert the cylindrical coordinates to spherical coordinates
      %
      [radius, colat, lon] = cspice_cylsph(r, lonc, z);

      %
      % ...convert angular measure to degrees.
      %
      colat = colat * cspice_dpr;
      lon  = lon    * cspice_dpr;
      lonc = lonc   * cspice_dpr;

      %
      % Output banner.
      %
      disp('     r         lonc        z        radius      lon       colat  ')
      disp('  --------   --------   --------   --------   --------   --------')

      %
      % Create an array of values for output.
      %
      output = [ r; lonc; z; radius; lon; colat ];

      txt = sprintf( '%10.4f %10.4f %10.4f %10.4f %10.4f %10.4f\n', output );
      disp( txt )

      %
      % It's always good form to unload kernels after use,
      % particularly in MATLAB due to data persistence.
      %
      cspice_kclear

   MATLAB outputs:

        r         lonc        z        radius      lon       colat
     --------   --------   --------   --------   --------   --------
       1.0000     0.0000     0.0000     1.0000     0.0000    90.0000
       1.0000    90.0000     0.0000     1.0000    90.0000    90.0000
       1.0000   180.0000     1.0000     1.4142   180.0000    45.0000
       1.0000   180.0000    -1.0000     1.4142   180.0000   135.0000
       0.0000   180.0000     1.0000     1.0000   180.0000     0.0000
       0.0000    33.0000     0.0000     0.0000    33.0000     0.0000

Particulars


   None.

Required Reading


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

   MICE.REQ

Version


   -Mice Version 1.0.1, 30-OCT-2014, EDW (JPL)

       Edited I/O section to conform to NAIF standard for Mice documentation.

   -Mice Version 1.0.0, 01-DEC-2005, EDW (JPL)

Index_Entries


   cylindrical to spherical


Wed Apr  5 18:00:30 2017