00001 /* 00002 * cartography.c ~rick/src/util 00003 * 00004 * Functions for mapping between plate, heliographic, and various map 00005 * coordinate systems, including scaling. 00006 * 00007 * Contents: 00008 * img2sphere Map from plate location to heliographic 00009 * coordinates 00010 * plane2sphere Map from map location to heliographic or 00011 * geographical coordinates 00012 * sphere2img Map from heliographic coordinates to plate 00013 * location 00014 * sphere2plane Map from heliographic/geographic coordinates 00015 * to map location 00016 * 00017 * Responsible: Rick Bogart RBogart@solar.Stanford.EDU 00018 * 00019 * Usage: 00020 * int img2sphere (double x, double y, double ang_r, double latc, 00021 * double lonc, double pa, double *rho, double *lat, double *lon, 00022 * double *sinlat, double *coslat, double *sig, double *mu, double *chi); 00023 * int plane2sphere (double x, double y, double latc, double lonc, 00024 * double *lat, double *lon, int projection); 00025 * int sphere2img (double lat, double lon, double latc, double lonc, 00026 * double *x, double *y, double xcenter, double ycenter, 00027 * double rsun, double peff, double ecc, double chi, 00028 * int xinvrt, int yinvrt); 00029 * int sphere2plane (double lat, double lon, double latc, double lonc, 00030 * double *x, double *y, int projection); 00031 * 00032 * Bugs: 00033 * It is assumed that the function atan2() returns the correct value 00034 * for the quadrant; not all libraries may support this feature. 00035 * sphere2img uses a constant for the correction due to the finite 00036 * distance to the sun. 00037 * sphere2plane and plane2sphere are not true inverses for the following 00038 * projections: (Lambert) cylindrical equal area, sinusoidal equal area 00039 * (Sanson- 00040 * Flamsteed), and Mercator; for these projections, sphere2plane is 00041 * implemented as the normal projection, while plane2sphere is implemented 00042 * as the oblique projection tangent at the normal to the central meridian 00043 * plane2sphere doesn't return 1 if the x coordinate would map to a point 00044 * off the surface. 00045 * 00046 * Planned updates: 00047 * Provide appropriate oblique versions for cylindrical and 00048 * pseudo-cylindrical projections in sphere2plane 00049 * 00050 * Revision history is at end of file. 00051 */ 00052 #include <math.h> 00053 00054 #define RECTANGULAR (0) 00055 #define CASSINI (1) 00056 #define MERCATOR (2) 00057 #define CYLEQA (3) 00058 #define SINEQA (4) 00059 #define GNOMONIC (5) 00060 #define POSTEL (6) 00061 #define STEREOGRAPHIC (7) 00062 #define ORTHOGRAPHIC (8) 00063 #define LAMBERT (9) 00064 #define AERIAL (10) 00065 00066 static double arc_distance (double lat, double lon, double latc, double lonc) { 00067 double cosa = sin (lat) * sin (latc) + 00068 cos (lat) * cos (latc) * cos (lon - lonc); 00069 return acos (cosa); 00070 } 00071 00072 int img2sphere (double x, double y, double ang_r, double latc, double lonc, 00073 double pa, double *rho, double *lat, double *lon, double *sinlat, 00074 double *coslat, double *sig, double *mu, double *chi) { 00075 /* 00076 * Map projected coordinates (x, y) to (lon, lat) and (rho | sig, chi) 00077 * 00078 * Arguments: 00079 * x } Plate locations, in units of the image radius, relative 00080 * y } to the image center 00081 * ang_r Apparent semi-diameter of sun (angular radius of sun at 00082 * the observer's tangent line) 00083 * latc Latitude of disc center, uncorrected for light travel time 00084 * lonc Longitude of disc center 00085 * pa Position angle of solar north on image, measured eastward 00086 * from north (sky coordinates) 00087 * Return values: 00088 * rho Angle point:sun_center:observer 00089 * lon Heliographic longitude 00090 * lat Heliographic latitude 00091 * sinlat sine of heliographic latitude 00092 * coslat cosine of heliographic latitude 00093 * sig Angle point:observer:sun_center 00094 * mu cosine of angle between the point:observer line and the 00095 * local normal 00096 * chi Position angle on image measured westward from solar 00097 * north 00098 * 00099 * All angles are in radians. 00100 * Return value is 1 if point is outside solar radius (in which case the 00101 * heliographic coordinates and mu are meaningless), 0 otherwise. 00102 * It is assumed that the image is direct; the x or y coordinates require a 00103 * sign change if the image is inverted. 00104 * 00105 */ 00106 static double ang_r0 = 0.0, sinang_r = 0.0, tanang_r = 0.0; 00107 static double latc0 = 0.0, coslatc = 1.0, sinlatc = 0.0; 00108 double cosr, sinr, sinlon, sinsig; 00109 00110 if (ang_r != ang_r0) { 00111 sinang_r = sin (ang_r); 00112 tanang_r = tan (ang_r); 00113 ang_r0 = ang_r; 00114 } 00115 if (latc != latc0) { 00116 sinlatc = sin (latc); 00117 coslatc = cos (latc); 00118 latc0 = latc; 00119 } 00120 *chi = atan2 (x, y) + pa; 00121 while (*chi > 2 * M_PI) *chi -= 2 * M_PI; 00122 while (*chi < 0.0) *chi += 2 * M_PI; 00123 /* Camera curvature correction, no small angle approximations */ 00124 *sig = atan (hypot (x, y) * tanang_r); 00125 sinsig = sin (*sig); 00126 *rho = asin (sinsig / sinang_r) - *sig; 00127 if (*sig > ang_r) return (-1); 00128 *mu = cos (*rho + *sig); 00129 sinr = sin (*rho); 00130 cosr = cos (*rho); 00131 00132 *sinlat = sinlatc * cos (*rho) + coslatc * sinr * cos (*chi); 00133 *coslat = sqrt (1.0 - *sinlat * *sinlat); 00134 *lat = asin (*sinlat); 00135 sinlon = sinr * sin (*chi) / *coslat; 00136 *lon = asin (sinlon); 00137 if (cosr < (*sinlat * sinlatc)) *lon = M_PI - *lon; 00138 *lon += lonc; 00139 while (*lon < 0.0) *lon += 2 * M_PI; 00140 while (*lon >= 2 * M_PI) *lon -= 2 * M_PI; 00141 return (0); 00142 } 00143 00144 int plane2sphere (double x, double y, double latc, double lonc, 00145 double *lat, double *lon, int projection) { 00146 /* 00147 * Perform the inverse mapping from rectangular coordinates x, y on a map 00148 * in a particular projection to heliographic (or geographic) coordinates 00149 * latitude and longitude (in radians). 00150 * The map coordinates are first transformed into arc and azimuth coordinates 00151 * relative to the center of the map according to the appropriate inverse 00152 * transformation for the projection, and thence to latitude and longitude 00153 * from the known heliographic coordinates of the map center (in radians). 00154 * The scale of the map coordinates is assumed to be in units of radians at 00155 * the map center (or other appropriate location of minimum distortion). 00156 * 00157 * Arguments: 00158 * x } Map coordinates, in units of radians at the scale 00159 * y } appropriate to the map center 00160 * latc Latitude of the map center (in radians) 00161 * lonc Longitude of the map center (in radians) 00162 * *lat Returned latitude (in radians) 00163 * *lon Returned longitude (in radians) 00164 * projection A code specifying the map projection to be used: see below 00165 * 00166 * The following projections are supported: 00167 * RECTANGULAR A "rectangular" mapping of x and y directly to 00168 * longitude and latitude, respectively; it is the 00169 * normal cylindrical equidistant projection (plate 00170 * carrée) tangent at the equator and equidistant 00171 * along meridians. Central latitudes off the equator 00172 * merely result in displacement of the map in y 00173 * Also known as CYLEQD 00174 * CASSINI The transverse cylindrical equidistant projection 00175 * (Cassini-Soldner) equidistant along great circles 00176 * perpendicular to the central meridian 00177 * MERCATOR Mercator's conformal projection, in which paths of 00178 * constant bearing are straight lines 00179 * CYLEQA Lambert's normal equal cylindrical (equal-area) 00180 * projection, in which evenly-spaced meridians are 00181 * evenly spaced in x and evenly-spaced parallels are 00182 * separated by the cosine of the latitude 00183 * SINEQA The Sanson-Flamsteed sinusoidal equal-area projection, 00184 * in which evenly-spaced parallels are evenly spaced in 00185 * y and meridians are sinusoidal curves 00186 * GNOMONIC The gnomonic, or central, projection, in which all 00187 * straight lines correspond to geodesics; projection 00188 * from the center of the sphere onto a tangent plane 00189 * POSTEL Postel's azimuthal equidistant projection, in which 00190 * straight lines through the center of the map are 00191 * geodesics with a uniform scale 00192 * STEREOGRAPHIC The stereographic projection, mapping from the 00193 * antipode of the map center onto a tangent plane 00194 * ORTHOGRAPHIC The orthographic projection, mapping from infinity 00195 * onto a tangent plane 00196 * LAMBERT Lambert's azimuthal equivalent projection 00197 * 00198 * The function returns -1 if the requested point on the map does not project 00199 * back to the sphere or is not a principal value, 1 if it projects to a 00200 * point on a hidden hemisphere (if that makes sense), 0 otherwise 00201 */ 00202 static double latc0 = 0.0, sinlatc = 0.0, coslatc = 1.0 ; 00203 double r, rm, test; 00204 double cosr, sinr, cosp, sinp, coslat, sinlat, sinlon; 00205 double sinphi, cosphi, phicom; 00206 int status = 0; 00207 00208 if (latc != latc0) { 00209 coslatc = cos (latc); 00210 sinlatc = sin (latc); 00211 } 00212 latc0 = latc; 00213 00214 switch (projection) { 00215 case (RECTANGULAR): 00216 *lon = lonc + x; 00217 *lat = latc + y; 00218 if (arc_distance (*lat, *lon, latc, lonc) > M_PI_2) status = 1; 00219 if (fabs (x) > M_PI || fabs (y) > M_PI_2) status = -1; 00220 return status; 00221 case (CASSINI): { 00222 double sinx = sin (x); 00223 double cosy = cos (y + latc); 00224 double siny = sin (y + latc); 00225 *lat = acos (sqrt (cosy * cosy + siny * siny * sinx * sinx)); 00226 if (y < -latc) *lat *= -1; 00227 *lon = (fabs (*lat) < M_PI_2) ? lonc + asin (sinx / cos (*lat)) : lonc; 00228 if (y > (M_PI_2 - latc) || y < (-M_PI_2 - latc)) 00229 *lon = 2 * lonc + M_PI - *lon; 00230 if (*lon < -M_PI) *lon += 2* M_PI; 00231 if (*lon > M_PI) *lon -= 2 * M_PI; 00232 if (arc_distance (*lat, *lon, latc, lonc) > M_PI_2) status = 1; 00233 if (fabs (x) > M_PI || fabs (y) > M_PI_2) status = -1; 00234 return status; 00235 } 00236 case (CYLEQA): 00237 if (fabs (y) > 1.0) { 00238 y = copysign (1.0, y); 00239 status = -1; 00240 } 00241 cosphi = sqrt (1.0 - y*y); 00242 *lat = asin ((y * coslatc) + (cosphi * cos (x) * sinlatc)); 00243 test = (cos (*lat) == 0.0) ? 0.0 : cosphi * sin (x) / cos (*lat); 00244 *lon = asin (test) + lonc; 00245 if (fabs (x) > M_PI_2) { 00246 status = 1; 00247 while (x > M_PI_2) { 00248 *lon = M_PI - *lon; 00249 x -= M_PI; 00250 } 00251 while (x < -M_PI_2) { 00252 *lon = -M_PI - *lon; 00253 x += M_PI; 00254 } 00255 } 00256 if (arc_distance (*lat, *lon, latc, lonc) > M_PI_2) status = 1; 00257 return status; 00258 case (SINEQA): 00259 cosphi = cos (y); 00260 if (cosphi <= 0.0) { 00261 *lat = y; 00262 *lon = lonc; 00263 if (cosphi < 0.0) status = -1; 00264 return status; 00265 } 00266 *lat = asin ((sin (y) * coslatc) + (cosphi * cos (x/cosphi) * sinlatc)); 00267 coslat = cos (*lat); 00268 if (coslat <= 0.0) { 00269 *lon = lonc; 00270 if (coslat < 0.0) status = 1; 00271 return status; 00272 } 00273 test = cosphi * sin (x/cosphi) / coslat; 00274 *lon = asin (test) + lonc; 00275 if (fabs (x) > M_PI * cosphi) return (-1); 00276 if (fabs (x) > M_PI_2) { 00277 status = 1; 00278 while (x > M_PI_2) { 00279 *lon = M_PI - *lon; 00280 x -= M_PI; 00281 } 00282 while (x < -M_PI_2) { 00283 *lon = -M_PI - *lon; 00284 x += M_PI; 00285 } 00286 } 00287 /* 00288 if (arc_distance (*lat, *lon, latc, lonc) > M_PI_2) status = 1; 00289 */ 00290 return status; 00291 case (MERCATOR): 00292 phicom = 2.0 * atan (exp (y)); 00293 sinphi = -cos (phicom); 00294 cosphi = sin (phicom); 00295 *lat = asin ((sinphi * coslatc) + (cosphi * cos (x) * sinlatc)); 00296 *lon = asin (cosphi * sin (x) / cos (*lat)) + lonc; 00297 if (arc_distance (*lat, *lon, latc, lonc) > M_PI_2) status = 1; 00298 if (fabs (x) > M_PI_2) status = -1; 00299 return status; 00300 } 00301 /* Convert to polar coordinates */ 00302 r = hypot (x, y); 00303 cosp = (r == 0.0) ? 1.0 : x / r; 00304 sinp = (r == 0.0) ? 0.0 : y / r; 00305 /* Convert to arc */ 00306 switch (projection) { 00307 case (POSTEL): 00308 rm = r; 00309 if (rm > M_PI_2) status = 1; 00310 break; 00311 case (GNOMONIC): 00312 rm = atan (r); 00313 break; 00314 case (STEREOGRAPHIC): 00315 rm = 2 * atan (0.5 * r); 00316 if (rm > M_PI_2) status = 1; 00317 break; 00318 case (ORTHOGRAPHIC): 00319 if ( r > 1.0 ) { 00320 r = 1.0; 00321 status = -1; 00322 } 00323 rm = asin (r); 00324 break; 00325 case (LAMBERT): 00326 if ( r > 2.0 ) { 00327 r = 2.0; 00328 status = -1; 00329 } 00330 rm = 2 * asin (0.5 * r); 00331 if (rm > M_PI_2 && status == 0) status = 1; 00332 break; 00333 } 00334 cosr = cos (rm); 00335 sinr = sin (rm); 00336 /* Convert to latitude-longitude */ 00337 sinlat = sinlatc * cosr + coslatc * sinr * sinp; 00338 *lat = asin (sinlat); 00339 coslat = cos (*lat); 00340 sinlon = (coslat == 0.0) ? 0.0 : sinr * cosp / coslat; 00341 /* This should never happen except for roundoff errors, but just in case: */ 00342 /* 00343 if (sinlon + 1.0 <= 0.0) *lon = -M_PI_2; 00344 else if (sinlon - 1.0 >= 0.0) *lon = M_PI_2; 00345 else 00346 */ 00347 *lon = asin (sinlon); 00348 /* Correction suggested by Dick Shine */ 00349 if (cosr < (sinlat * sinlatc)) *lon = M_PI - *lon; 00350 *lon += lonc; 00351 return status; 00352 } 00353 00354 int sphere2img (double lat, double lon, double latc, double lonc, 00355 double *x, double *y, double xcenter, double ycenter, 00356 double rsun, double peff, double ecc, double chi, 00357 int xinvrt, int yinvrt) { 00358 /* 00359 * Perform a mapping from heliographic coordinates latitude and longitude 00360 * (in radians) to plate location on an image of the sun. The plate 00361 * location is in units of the image radius and is given relative to 00362 * the image center. The function returns 1 if the requested point is 00363 * on the far side (>90 deg from disc center), 0 otherwise. 00364 * 00365 * Arguments: 00366 * lat Latitude (in radians) 00367 * lon Longitude (in radians) 00368 * latc Heliographic latitude of the disc center (in radians) 00369 * lonc Heliographic longitude of the disc center (in radians) 00370 * *x } Plate locations, in units of the image radius, relative 00371 * *y } to the image center 00372 * xcenter } Plate locations of the image center, in units of the 00373 * ycenter } image radius, and measured from an arbitrary origin 00374 * (presumably the plate center or a corner) 00375 * rsun Apparent semi-diameter of the solar disc, in plate 00376 * coordinates 00377 * peff Position angle of the heliographic pole, measured 00378 * eastward from north, relative to the north direction 00379 * on the plate, in radians 00380 * ecc Eccentricity of the fit ellipse presumed due to image 00381 * distortion (no distortion in direction of major axis) 00382 * chi Position angle of the major axis of the fit ellipse, 00383 * measure eastward from north, relative to the north 00384 * direction on the plate, in radians (ignored if ecc = 0) 00385 * xinvrt} Flag parameters: if not equal to 0, the respective 00386 * yinvrt} coordinates on the image x and y are inverted 00387 * 00388 * The heliographic coordinates are first mapped into the polar coordinates 00389 * in an orthographic projection centered at the appropriate location and 00390 * oriented with north in direction of increasing y and west in direction 00391 * of increasing x. The radial coordinate is corrected for foreshortening 00392 * due to the finite distance to the Sun. If the eccentricity of the fit 00393 * ellipse is non-zero the coordinate of the mapped point is proportionately 00394 * reduced in the direction parallel to the minor axis. 00395 * 00396 * Bugs: 00397 * The finite distance correction uses a fixed apparent semi-diameter 00398 * of 16'01'' appropriate to 1.0 AU. In principle the plate radius could 00399 * be used, but this would require the plate scale to be supplied and the 00400 * correction would probably be erroneous and in any case negligible. 00401 * 00402 * The ellipsoidal correction has not been tested very thoroughly. 00403 * 00404 * The return value is based on a test which does not take foreshortening 00405 * into account. 00406 */ 00407 static double sin_asd = 0.004660, cos_asd = 0.99998914; 00408 /* appropriate to 1 AU */ 00409 static double last_latc = 0.0, cos_latc = 1.0, sin_latc = 0.0; 00410 double r, cos_cang, xr, yr; 00411 double sin_lat, cos_lat, cos_lat_lon, cospa, sinpa; 00412 double squash, cchi, schi, c2chi, s2chi, xp, yp; 00413 int hemisphere; 00414 00415 if (latc != last_latc) { 00416 sin_latc = sin (latc); 00417 cos_latc = cos (latc); 00418 last_latc = latc; 00419 } 00420 sin_lat = sin (lat); 00421 cos_lat = cos (lat); 00422 cos_lat_lon = cos_lat * cos (lon - lonc); 00423 00424 cos_cang = sin_lat * sin_latc + cos_latc * cos_lat_lon; 00425 hemisphere = (cos_cang < 0.0) ? 1 : 0; 00426 r = rsun * cos_asd / (1.0 - cos_cang * sin_asd); 00427 xr = r * cos_lat * sin (lon - lonc); 00428 yr = r * (sin_lat * cos_latc - sin_latc * cos_lat_lon); 00429 /* Change sign for inverted images */ 00430 if (xinvrt) xr *= -1.0; 00431 if (yinvrt) yr *= -1.0; 00432 /* Correction for ellipsoidal squashing of image */ 00433 if (ecc > 0.0 && ecc < 1.0) { 00434 squash = sqrt (1.0 - ecc * ecc); 00435 cchi = cos (chi); 00436 schi = sin (chi); 00437 s2chi = schi * schi; 00438 c2chi = 1.0 - s2chi; 00439 xp = xr * (s2chi + squash * c2chi) - yr * (1.0 - squash) * schi * cchi; 00440 yp = yr * (c2chi + squash * s2chi) - xr * (1.0 - squash) * schi * cchi; 00441 xr = xp; 00442 yr = yp; 00443 } 00444 00445 cospa = cos (peff); 00446 sinpa = sin (peff); 00447 *x = xr * cospa - yr * sinpa; 00448 *y = xr * sinpa + yr * cospa; 00449 00450 *y += ycenter; 00451 *x += xcenter; 00452 00453 return (hemisphere); 00454 } 00455 00456 int sphere2plane (double lat, double lon, double latc, double lonc, 00457 double *x, double *y, int projection) { 00458 /* 00459 * Perform a mapping from heliographic (or geographic or celestial) 00460 * coordinates latitude and longitude (in radians) to map location in 00461 * the given projection. The function returns 1 if the requested point is 00462 * on the far side (>90 deg from disc center), 0 otherwise. 00463 * 00464 * Arguments: 00465 * lat Latitude (in radians) 00466 * lon Longitude (in radians) 00467 * latc Heliographic latitude of the disc center (in radians) 00468 * lonc Heliographic longitude of the disc center (in radians) 00469 * *x } Plate locations, in units of the image radius, relative 00470 * *y } to the image center 00471 * projection code specifying the map projection to be used: 00472 * see plane2sphere 00473 */ 00474 static double last_latc = 0.0, cos_latc = 1.0, sin_latc = 0.0, yc_merc; 00475 double r, rm, cos_cang; 00476 double sin_lat, cos_lat, cos_lat_lon; 00477 int hemisphere; 00478 00479 if (latc != last_latc) { 00480 sin_latc = sin (latc); 00481 cos_latc = cos (latc); 00482 last_latc = latc; 00483 yc_merc = log (tan (M_PI_4 + 0.5 * latc)); 00484 } 00485 sin_lat = sin (lat); 00486 cos_lat = cos (lat); 00487 cos_lat_lon = cos_lat * cos (lon - lonc); 00488 cos_cang = sin_lat * sin_latc + cos_latc * cos_lat_lon; 00489 hemisphere = (cos_cang < 0.0) ? 1 : 0; 00490 /* Cylindrical projections */ 00491 switch (projection) { 00492 /* Normal cylindrical equidistant */ 00493 case (RECTANGULAR): 00494 *x = lon - lonc; 00495 *y = lat - latc; 00496 return hemisphere; 00497 /* Transverse cylindrical equidistant */ 00498 case (CASSINI): 00499 *x = asin (cos_lat * sin (lon - lonc)); 00500 *y = atan2 (tan (lat), cos (lon - lonc)) - latc; 00501 return hemisphere; 00502 /* Normal cylindrical equivalent - differs from sphere2plane */ 00503 case (CYLEQA): 00504 *x = lon - lonc; 00505 *y = sin_lat - sin_latc; 00506 return hemisphere; 00507 /* Normal sinusoidal equivalent - differs from sphere2plane */ 00508 case (SINEQA): 00509 *x = cos_lat * (lon - lonc); 00510 *y = lat - latc; 00511 return hemisphere; 00512 /* Normal Mercator - differs from sphere2plane */ 00513 case (MERCATOR): 00514 *x = lon - lonc; 00515 *y = log (tan (M_PI_4 + 0.5 * lat)) - yc_merc; 00516 return hemisphere; 00517 } 00518 /* Azimuthal projections */ 00519 rm = acos (cos_cang); 00520 00521 switch (projection) { 00522 case (POSTEL): 00523 r = rm; 00524 break; 00525 case (GNOMONIC): 00526 r = tan (rm); 00527 break; 00528 case (STEREOGRAPHIC): 00529 r = 2.0 * tan (0.5 * rm); 00530 break; 00531 case (ORTHOGRAPHIC): 00532 r = sin (rm); 00533 break; 00534 case (LAMBERT): 00535 r = 2.0 * sin (0.5 * rm); 00536 break; 00537 default: 00538 return -1; 00539 } 00540 if (rm != 0.) { 00541 *x = r * cos_lat * sin (lon - lonc) / sin (rm); 00542 *y = r * (sin_lat * cos_latc - sin_latc * cos_lat_lon) / sin(rm); 00543 } else { 00544 *x = 0.; 00545 *y = 0.; 00546 } 00547 return hemisphere; 00548 } 00549 00550 /* 00551 * Revision History 00552 * v 0.9 94.08.03 Rick Bogart created this file 00553 * 94.10.27 R Bogart reorganized for inclusion in libM 00554 * 94.11.24 R Bogart fixed bug in sinusoidal equal-area 00555 * mapping and minor bug in cylindrical equal-area mapoing 00556 * (latc != 0); added Mercator projection; more comments 00557 * 94.12.12 R Bogart & Luiz Sa fixed non-azimuthal projections 00558 * in plane2sphere to support center of map at other than L0L0; 00559 * removed unnecessary (and incorrect) scaling in azimuthal 00560 * mappings 00561 * v 1.0 95.08.18 R Bogart & L Sa implemented optimum_scale(); 00562 * added arguments and code to sphere2img() to deal with elliptic 00563 * images and image inversion; additional comments; 00564 * minor fix in SINEQA option of plane2sphere(); changed sign on 00565 * on position angle used in sphere2img() to conform with standard 00566 * usage (positive eastward from north in sky) 00567 * 96.05.17 R Bogart fixed bug in longitude calculation of 00568 * points "over the pole" for azimuthal projections in plane2sphere() 00569 * and corrected bug in sphere2img(). 00570 * 96.06.07 R Bogart return status of sphere2img indicates 00571 * whether mapped point is on far side of globe. 00572 * 96.12.18 R Bogart removed debugging prints from function 00573 * optimum_scale() 00574 * 97.01.21 R Bogart plane2sphere now returns status 00575 * 98.09.02 R Bogart added img2sphere 00576 * 99.02.25 R Bogart fixed calculated chi in img2sphere to 00577 * conform to man page description; plane2sphere now returns 1 if 00578 * requested point is not principal value in rectangular, cylindrical 00579 * equal-area, sinusoidal equal-area, and Mercator projections 00580 * 99.12.13 R Bogart added sphere2plane 00581 * 00.04.24 R Bogart modifications to plane2sphere to avoid 00582 * occasional roundoff errors leading to undefined results at the 00583 * limb 00584 * 05.01.07 R Bogart fixed bug in longitude calculation in 00585 * plane2sphere() for points more than 90deg from target longitude 00586 * of map center 00587 * 06.11.10 R Bogart fixed return value of sphere2plane for 00588 * cylindrical projection(s); added support for Cassini's projection 00589 * (transverse cylindrical equidistant); added support for normal 00590 * cylindrical and pseudocylindrical projections to sphere2plane 00591 * 09.07.02 R Bogart copied to private location for inclusion in 00592 * DRMS modules and standalone code; removed optimum_scale(), pow2scale(), 00593 * name2proj(), proj2name() 00594 * 09.12.02 R Bogart fixed two icc11 compiler warnings 00595 */