sphcyl_c |
Table of contents
Proceduresphcyl_c ( Spherical to cylindrical coordinates ) void sphcyl_c ( SpiceDouble radius, SpiceDouble colat, SpiceDouble slon, SpiceDouble * r, SpiceDouble * clon, SpiceDouble * z ) AbstractConvert from spherical coordinates to cylindrical coordinates. Required_ReadingNone. KeywordsCONVERSION COORDINATES Brief_I/OVARIABLE I/O DESCRIPTION -------- --- ------------------------------------------------- radius I Distance of point from origin. colat I Polar angle (co-latitude in radians) of point. slon I Azimuthal angle (longitude) of point (radians). r O Distance of point from Z axis. clon O Angle (radians) of point from XZ plane. z O Height of point above XY plane. Detailed_Inputradius is the distance of the point from origin. colat is the polar angle (co-latitude in radians) of the point. slon is the azimuthal angle (longitude) of the point (radians). Detailed_Outputr is the distance of the point of interest from Z axis. clon is the cylindrical angle (radians) of the point from the XZ plane. `clon' is set equal to `slon'. z is the height of the point above XY plane. ParametersNone. ExceptionsError free. FilesNone. ParticularsThis returns the cylindrical coordinates of a point whose position is input through spherical coordinates. ExamplesThe 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 spherical coordinates of the position of the Moon as seen from the Earth, and convert them to cylindrical and rectangular coordinates. Use the meta-kernel shown below to load the required SPICE kernels. KPL/MK File name: sphcyl_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 KERNELS_TO_LOAD = ( 'de421.bsp', 'naif0012.tls' ) \begintext End of meta-kernel Example code begins here. /. Program sphcyl_ex1 ./ #include <stdio.h> #include "SpiceUsr.h" int main( ) { /. Local variables ./ SpiceDouble clon; SpiceDouble colat; SpiceDouble et; SpiceDouble lt; SpiceDouble pos [3]; SpiceDouble r; SpiceDouble radius; SpiceDouble rectan [3]; SpiceDouble slon; SpiceDouble z; /. Load SPK and LSK kernels, use a meta kernel for convenience. ./ furnsh_c ( "sphcyl_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, < ); /. Convert the position vector `pos' to spherical coordinates. ./ recsph_c ( pos, &radius, &colat, &slon ); /. Convert the spherical coordinates to cylindrical. ./ sphcyl_c ( radius, colat, slon, &r, &clon, &z ); /. Convert the cylindrical coordinates to rectangular. ./ cylrec_c ( r, clon, z, rectan ); printf( " \n" ); printf( "Original rectangular coordinates:\n" ); printf( " \n" ); printf( " X (km): %19.8f\n", pos[0] ); printf( " Y (km): %19.8f\n", pos[1] ); printf( " Z (km): %19.8f\n", pos[2] ); printf( " \n" ); printf( "Spherical coordinates:\n" ); printf( " \n" ); printf( " Radius (km): %19.8f\n", radius ); printf( " Colatitude (deg): %19.8f\n", colat*dpr_c ( ) ); printf( " Longitude (deg): %19.8f\n", slon*dpr_c ( ) ); 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[0] ); printf( " Y (km): %19.8f\n", rectan[1] ); printf( " Z (km): %19.8f\n", rectan[2] ); 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 Spherical coordinates: Radius (km): 403626.33912495 Colatitude (deg): 108.26566077 Longitude (deg): -98.34959789 Cylindrical coordinates: Radius (km): 383289.01777726 Longitude (deg): -98.34959789 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 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. /. Program sphcyl_ex2 ./ #include <stdio.h> #include "SpiceUsr.h" int main( ) { /. Local parameters. ./ #define NREC 11 /. Local variables. ./ SpiceDouble clon; SpiceDouble r; SpiceDouble rcolat; SpiceDouble rslon; SpiceDouble z; SpiceInt i; /. Define the input spherical coordinates. Angles in degrees. ./ SpiceDouble radius [NREC] = { 0.0, 1.0, 1.0, 1.0, 1.4142, 1.0, 1.0, 1.0, 1.4142, 1.0, 0.0 }; SpiceDouble colat [NREC] = { 0.0, 90.0, 90.0, 0.0, 45.0, 90.0, 180.0, 90.0, 135.0, 0.0, 90.0 }; SpiceDouble slon [NREC] = { 0.0, 0.0, 90.0, 0.0, 180.0, -90.0, 0.0, 45.0, 180.0, 180.0, 33.0 }; /. Print the banner. ./ printf( " radius colat slon r clon z\n" ); printf( " ------- ------- ------- ------- ------- -------\n" ); /. Do the conversion. Output angles in degrees. ./ for ( i = 0; i < NREC; i++ ) { rcolat = colat[i] * rpd_c ( ); rslon = slon[i] * rpd_c ( ); sphcyl_c ( radius[i], rcolat, rslon, &r, &clon, &z ); printf( "%8.3f %8.3f %8.3f ", radius[i], colat[i], slon[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: radius colat slon r clon z ------- ------- ------- ------- ------- ------- 0.000 0.000 0.000 0.000 0.000 0.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 0.000 0.000 1.000 1.414 45.000 180.000 1.000 180.000 1.000 1.000 90.000 -90.000 1.000 -90.000 0.000 1.000 180.000 0.000 0.000 0.000 -1.000 1.000 90.000 45.000 1.000 45.000 0.000 1.414 135.000 180.000 1.000 180.000 -1.000 1.000 0.000 180.000 0.000 180.000 1.000 0.000 90.000 33.000 0.000 33.000 0.000 3) Other than the obvious conversion between coordinate systems this routine could be used to obtain the axial projection from a sphere to a cylinder about the z-axis that contains the equator of the sphere. Such a projection is valuable because it preserves the areas between regions on the sphere and their projections to the cylinder. Example code begins here. /. Program sphcyl_ex3 ./ #include <stdio.h> #include "SpiceUsr.h" int main( ) { /. Local variables ./ SpiceDouble clon; SpiceDouble colat; SpiceDouble radius; SpiceDouble r; SpiceDouble slon; SpiceDouble z; /. Define the point whose projection is to be computed. ./ radius = 100.0; slon = 45.0 * rpd_c(); colat = 102.5 * rpd_c(); /. Convert the spherical coordinates to cylindrical. ./ sphcyl_c ( radius, colat, slon, &r, &clon, &z ); printf( "Coordinates of the projected point on cylinder:\n" ); printf( " \n" ); printf( " Radius (km): %22.11f\n", r ); printf( " Longitude (deg): %22.11f\n", clon*dpr_c() ); printf( " Z (km): %22.11f\n", z ); return ( 0 ); } When this program was executed on a Mac/Intel/cc/64-bit platform, the output was: Coordinates of the projected point on cylinder: Radius (km): 97.62960071199 Longitude (deg): 45.00000000000 Z (km): -21.64396139381 RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionJ. Diaz del Rio (ODC Space) B.V. Semenov (JPL) E.D. Wright (JPL) Version-CSPICE Version 1.1.0, 05-JUL-2021 (JDR) Changed the output argument name "lon" to "clon" for consistency with other routines. Edited the header to comply with NAIF standard. Added complete code examples. -CSPICE Version 1.0.1, 26-JUL-2016 (BVS) Minor headers edits. -CSPICE Version 1.0.0, 08-FEB-1998 (EDW) Index_Entriesspherical to cylindrical coordinates |
Fri Dec 31 18:41:12 2021