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
reccyl_c

 Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input Detailed_Output Parameters Exceptions Files Particulars Examples Restrictions Literature_References Author_and_Institution Version Index_Entries

Procedure

reccyl_c ( Rectangular to cylindrical coordinates )

void reccyl_c ( ConstSpiceDouble     rectan,
SpiceDouble        * r,
SpiceDouble        * clon,
SpiceDouble        * z         )

Abstract

Convert from rectangular to cylindrical coordinates.

None.

CONVERSION
COORDINATES

Brief_I/O

VARIABLE  I/O  DESCRIPTION
--------  ---  -------------------------------------------------
rectan     I   Rectangular coordinates of a point.
r          O   Distance of the point from Z axis.
clon       O   Angle (radians) of the point from XZ plane
z          O   Height of the point above XY plane.

Detailed_Input

rectan      are the rectangular coordinates of the point of interest.

Detailed_Output

r           is the distance of the point of interest from Z axis.

clon        is the cylindrical angle (in radians) of the point of
interest from XZ plane. The `clon' range is [0, 2pi].

z           is the height of the point above XY plane.

None.

Error free.

None.

Particulars

This routine transforms the coordinates of a point from
rectangular to cylindrical coordinates.

Examples

The numerical results shown for these examples may differ across
platforms. The results depend on the SPICE kernels used as
input, the compiler and supporting libraries, and the machine
specific arithmetic implementation.

1) Compute the cylindrical coordinates of the position of the Moon
as seen from the Earth, and convert them to rectangular
coordinates.

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

KPL/MK

File name: reccyl_ex1.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

'naif0012.tls'  )

\begintext

End of meta-kernel

Example code begins here.

/.
Program reccyl_ex1
./
#include <stdio.h>
#include "SpiceUsr.h"

int main( )
{

/.
Local variables
./
SpiceDouble          clon;
SpiceDouble          et;
SpiceDouble          lt;
SpiceDouble          pos    ;
SpiceDouble          rectan ;
SpiceDouble          r;
SpiceDouble          z;

/.
Load SPK and LSK kernels, use a meta kernel for
convenience.
./
furnsh_c ( "reccyl_ex1.tm" );

/.
Look up the geometric state of the Moon as seen from
the Earth at 2017 Mar 20, relative to the J2000
reference frame.
./
str2et_c ( "2017 Mar 20", &et );

spkpos_c ( "Moon", et, "J2000", "NONE", "Earth", pos, &lt );

/.
Convert the position vector `pos' to cylindrical
coordinates.
./
reccyl_c ( pos, &r, &clon, &z );

/.
Convert the cylindrical to rectangular coordinates.
./

cylrec_c ( r, clon, z, rectan );

printf( " \n" );
printf( "Original rectangular coordinates:\n" );
printf( " \n" );
printf( " X          (km):  %19.8f\n", pos );
printf( " Y          (km):  %19.8f\n", pos );
printf( " Z          (km):  %19.8f\n", pos );
printf( " \n" );
printf( "Cylindrical coordinates:\n" );
printf( " \n" );
printf( " Radius     (km):  %19.8f\n", r );
printf( " Longitude (deg):  %19.8f\n", clon*dpr_c ( ) );
printf( " Z          (km):  %19.8f\n", z );
printf( " \n" );
printf( "Rectangular coordinates from cylrec_c:\n" );
printf( " \n" );
printf( " X          (km):  %19.8f\n", rectan );
printf( " Y          (km):  %19.8f\n", rectan );
printf( " Z          (km):  %19.8f\n", rectan );
printf( " \n" );

return ( 0 );
}

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

Original rectangular coordinates:

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

Cylindrical coordinates:

Longitude (deg):         261.65040211
Z          (km):     -126505.93063865

Rectangular coordinates from cylrec_c:

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

2) Create a table showing a variety of rectangular coordinates
and the corresponding cylindrical coordinates.

Corresponding rectangular and cylindrical coordinates are
listed to three decimal places. Output angles are in degrees.

Example code begins here.

/.
Program reccyl_ex2
./
#include <stdio.h>
#include "SpiceUsr.h"

int main( )
{

/.
Local parameters.
./
#define NREC         11

/.
Local variables.
./
SpiceDouble          clon;
SpiceDouble          r;
SpiceDouble          z;

SpiceInt             i;

/.
Define the input rectangular coordinates.
./
SpiceDouble          rectan [NREC] = {
{ 0.0,         0.0,         0.0},
{ 1.0,         0.0,         0.0},
{ 0.0,         1.0,         0.0},
{ 0.0,         0.0,         1.0},
{-1.0,         0.0,         0.0},
{ 0.0,        -1.0,         0.0},
{ 0.0,         0.0,        -1.0},
{ 1.0,         1.0,         0.0},
{ 1.0,         0.0,         1.0},
{ 0.0,         1.0,         1.0},
{ 1.0,         1.0,         1.0} };

/.
Print the banner.
./
printf( " rect  rect  rect     r       clon      z\n"    );
printf( " -------  -------  -------  -------  -------  -------\n" );

/.
Do the conversion. Output angles in degrees.
./
for ( i = 0; i < NREC; i++ )
{

reccyl_c ( rectan[i], &r, &clon, &z );

printf( "%8.3f %8.3f %8.3f ", rectan[i], rectan[i],
rectan[i]               );
printf( "%8.3f %8.3f %8.3f\n", r, clon * dpr_c ( ), z );

}

return ( 0 );
}

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

rect  rect  rect     r       clon      z
-------  -------  -------  -------  -------  -------
0.000    0.000    0.000    0.000    0.000    0.000
1.000    0.000    0.000    1.000    0.000    0.000
0.000    1.000    0.000    1.000   90.000    0.000
0.000    0.000    1.000    0.000    0.000    1.000
-1.000    0.000    0.000    1.000  180.000    0.000
0.000   -1.000    0.000    1.000  270.000    0.000
0.000    0.000   -1.000    0.000    0.000   -1.000
1.000    1.000    0.000    1.414   45.000    0.000
1.000    0.000    1.000    1.000    0.000    1.000
0.000    1.000    1.000    1.000   90.000    1.000
1.000    1.000    1.000    1.414   45.000    1.000

None.

None.

Author_and_Institution

N.J. Bachman        (JPL)
J. Diaz del Rio     (ODC Space)
B.V. Semenov        (JPL)
W.L. Taber          (JPL)
E.D. Wright         (JPL)

Version

-CSPICE Version 1.3.0, 04-JUL-2021 (JDR)

Changed the output argument name "lon" to "clon" for consistency
with other routines.

Edited the header to comply with NAIF standard.

-CSPICE Version 1.2.1, 26-JUL-2016 (BVS)

-CSPICE Version 1.2.0, 28-AUG-2001 (NJB)

Removed tab characters from source file. Include interface