| [1457] | 1 | /* function to convert between alt/az and ha/dec. | 
|---|
|  | 2 | */ | 
|---|
|  | 3 |  | 
|---|
|  | 4 | #include <stdio.h> | 
|---|
|  | 5 | #include <math.h> | 
|---|
|  | 6 |  | 
|---|
|  | 7 | #include "P_.h" | 
|---|
|  | 8 | #include "astro.h" | 
|---|
|  | 9 |  | 
|---|
|  | 10 | static void aaha_aux P_((double lat, double x, double y, double *p, double *q)); | 
|---|
|  | 11 |  | 
|---|
|  | 12 | /* given geographical latitude (n+, radians), lat, altitude (up+, radians), | 
|---|
|  | 13 | * alt, and azimuth (angle round to the east from north+, radians), | 
|---|
|  | 14 | * return hour angle (radians), ha, and declination (radians), dec. | 
|---|
|  | 15 | */ | 
|---|
|  | 16 | void | 
|---|
|  | 17 | aa_hadec (lat, alt, az, ha, dec) | 
|---|
|  | 18 | double lat; | 
|---|
|  | 19 | double alt, az; | 
|---|
|  | 20 | double *ha, *dec; | 
|---|
|  | 21 | { | 
|---|
|  | 22 | aaha_aux (lat, az, alt, ha, dec); | 
|---|
|  | 23 | if (*ha > PI) | 
|---|
|  | 24 | *ha -= 2*PI; | 
|---|
|  | 25 | } | 
|---|
|  | 26 |  | 
|---|
|  | 27 | /* given geographical (n+, radians), lat, hour angle (radians), ha, and | 
|---|
|  | 28 | * declination (radians), dec, return altitude (up+, radians), alt, and | 
|---|
|  | 29 | * azimuth (angle round to the east from north+, radians), | 
|---|
|  | 30 | */ | 
|---|
|  | 31 | void | 
|---|
|  | 32 | hadec_aa (lat, ha, dec, alt, az) | 
|---|
|  | 33 | double lat; | 
|---|
|  | 34 | double ha, dec; | 
|---|
|  | 35 | double *alt, *az; | 
|---|
|  | 36 | { | 
|---|
|  | 37 | aaha_aux (lat, ha, dec, az, alt); | 
|---|
|  | 38 | } | 
|---|
|  | 39 |  | 
|---|
|  | 40 | #ifdef NEED_GEOC | 
|---|
|  | 41 | /* given a geographic (surface-normal) latitude, phi, return the geocentric | 
|---|
|  | 42 | * latitude, psi. | 
|---|
|  | 43 | */ | 
|---|
|  | 44 | double | 
|---|
|  | 45 | geoc_lat (phi) | 
|---|
|  | 46 | double phi; | 
|---|
|  | 47 | { | 
|---|
|  | 48 | #define MAXLAT  degrad(89.9999) /* avoid tan() greater than this */ | 
|---|
|  | 49 | return (fabs(phi)>MAXLAT ? phi : atan(tan(phi)/1.00674)); | 
|---|
|  | 50 | } | 
|---|
|  | 51 | #endif | 
|---|
|  | 52 |  | 
|---|
|  | 53 | /* the actual formula is the same for both transformation directions so | 
|---|
|  | 54 | * do it here once for each way. | 
|---|
|  | 55 | * N.B. all arguments are in radians. | 
|---|
|  | 56 | */ | 
|---|
|  | 57 | static void | 
|---|
|  | 58 | aaha_aux (lat, x, y, p, q) | 
|---|
|  | 59 | double lat; | 
|---|
|  | 60 | double x, y; | 
|---|
|  | 61 | double *p, *q; | 
|---|
|  | 62 | { | 
|---|
|  | 63 | static double last_lat = -3434, slat, clat; | 
|---|
|  | 64 | double cap, B; | 
|---|
|  | 65 |  | 
|---|
|  | 66 | if (lat != last_lat) { | 
|---|
|  | 67 | slat = sin(lat); | 
|---|
|  | 68 | clat = cos(lat); | 
|---|
|  | 69 | last_lat = lat; | 
|---|
|  | 70 | } | 
|---|
|  | 71 |  | 
|---|
|  | 72 | solve_sphere (-x, PI/2-y, slat, clat, &cap, &B); | 
|---|
|  | 73 | *p = B; | 
|---|
|  | 74 | *q = PI/2 - acos(cap); | 
|---|
|  | 75 | } | 
|---|
|  | 76 |  | 
|---|
|  | 77 | /* For RCS Only -- Do Not Edit */ | 
|---|
| [1719] | 78 | static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: aa_hadec.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"}; | 
|---|