1 /* 2 3 -Procedure sphcyl_c ( Spherical to cylindrical coordinates ) 4 5 -Abstract 6 7 This routine converts from spherical coordinates to cylindrical 8 coordinates. 9 10 -Disclaimer 11 12 THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE 13 CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. 14 GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE 15 ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE 16 PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" 17 TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY 18 WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A 19 PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC 20 SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE 21 SOFTWARE AND RELATED MATERIALS, HOWEVER USED. 22 23 IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA 24 BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT 25 LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, 26 INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, 27 REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE 28 REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. 29 30 RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF 31 THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY 32 CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE 33 ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. 34 35 -Required_Reading 36 37 None. 38 39 -Keywords 40 41 CONVERSION, COORDINATES 42 43 */ 44 45 #include <math.h> 46 #include "SpiceUsr.h" 47 48 sphcyl_c(SpiceDouble radius,SpiceDouble colat,SpiceDouble slon,SpiceDouble * r,SpiceDouble * lon,SpiceDouble * z)49 void sphcyl_c ( SpiceDouble radius, 50 SpiceDouble colat, 51 SpiceDouble slon, 52 SpiceDouble * r, 53 SpiceDouble * lon, 54 SpiceDouble * z ) 55 56 /* 57 58 -Brief_I/O 59 60 VARIABLE I/O DESCRIPTION 61 -------- --- ------------------------------------------------- 62 radius I Distance of point from origin. 63 colat I Polar angle (co-latitude in radians) of point. 64 slon I Azimuthal angle (longitude) of point (radians). 65 r O Distance of point from Z axis. 66 lon O angle (radians) of point from XZ plane. 67 z O Height of point above XY plane. 68 69 -Detailed_Input 70 71 radius Distance of the point from origin. 72 73 colat Polar angle (co-latitude in radians) of the point. 74 75 slon Azimuthal angle (longitude) of the point (radians). 76 77 -Detailed_Output 78 79 r Distance of the point of interest from Z axis. 80 81 lon cylindrical angle (radians) of the point from the 82 XZ plane. `lon' is set equal to `slon'. 83 84 z Height of the point above XY plane. 85 86 -Parameters 87 88 None. 89 90 -Exceptions 91 92 Error free. 93 94 -Files 95 96 None. 97 98 -Particulars 99 100 This returns the cylindrical coordinates of a point whose 101 position is input through spherical coordinates. 102 103 -Examples 104 105 Other than the obvious conversion between coordinate systems 106 this routine could be used to obtain the axial projection 107 from a sphere to a cylinder about the z-axis that contains 108 the equator of the sphere. The following code fragment 109 illustrates this idea. 110 111 sphcyl_c ( radius, colat, lon, r, lon, z ) 112 r = radius 113 114 r, lon, and z now contain the coordinates of the projected 115 point. Such a projection is valuable because it preserves the 116 areas between regions on the sphere and their projections to the 117 cylinder. 118 119 -Restrictions 120 121 None. 122 123 -Literature_References 124 125 None. 126 127 -Author_and_Institution 128 129 W.L. Taber (JPL) 130 E.D. Wright (JPL) 131 132 -Version 133 134 -CSPICE Version 1.0.1, 26-JUL-2016 (BVS) 135 136 Minor headers edits. 137 138 -CSPICE Version 1.0.0, 08-FEB-1998 (EDW) 139 140 -Index_Entries 141 142 spherical to cylindrical coordinates 143 144 -& 145 */ 146 147 { /* Begin sphcyl_c */ 148 149 /* 150 Local variables 151 */ 152 153 SpiceDouble rr; 154 SpiceDouble zz; 155 156 /* 157 Convert to cylindrical coordinates, storing the results in 158 temporary variables. 159 */ 160 161 rr = radius * sin( colat ); 162 zz = radius * cos( colat ); 163 164 165 /* Move the results to the output variables. */ 166 167 *lon = slon; 168 *r = rr; 169 *z = zz; 170 171 172 } /* End sphcyl_c */ 173