wkj | cd5bae7 | 2004-04-21 02:16:43 +0000 | [diff] [blame] | 1 | #include "astro.h" |
| 2 | |
| 3 | void |
| 4 | geo(void) |
| 5 | { |
| 6 | |
| 7 | /* |
| 8 | * uses alpha, delta, rp |
| 9 | */ |
| 10 | |
| 11 | /* |
| 12 | * sets ra, decl, lha, decl2, az, el |
| 13 | */ |
| 14 | |
| 15 | /* |
| 16 | * geo converts geocentric equatorial coordinates |
| 17 | * to topocentric equatorial and topocentric horizon |
| 18 | * coordinates. |
| 19 | * All are (usually) referred to the true equator. |
| 20 | */ |
| 21 | |
| 22 | double sel, saz, caz; |
| 23 | double f; |
| 24 | double sa, ca, sd; |
| 25 | |
| 26 | /* |
| 27 | * convert to local hour angle and declination |
| 28 | */ |
| 29 | |
| 30 | lha = gst - alpha - wlong; |
| 31 | decl = delta; |
| 32 | |
| 33 | /* |
| 34 | * compute diurnal parallax (requires geocentric latitude) |
| 35 | */ |
| 36 | |
| 37 | sa = cos(decl)*sin(lha); |
| 38 | ca = cos(decl)*cos(lha) - erad*cos(glat)*sin(hp); |
| 39 | sd = sin(decl) - erad*sin(glat)*sin(hp); |
| 40 | |
| 41 | lha = atan2(sa, ca); |
| 42 | decl2 = atan2(sd, sqrt(sa*sa+ca*ca)); |
| 43 | f = sqrt(sa*sa+ca*ca+sd*sd); |
| 44 | semi2 = semi/f; |
| 45 | ra = gst - lha - wlong; |
| 46 | ra = pinorm(ra); |
| 47 | |
| 48 | /* |
| 49 | * convert to horizon coordinates |
| 50 | */ |
| 51 | |
| 52 | sel = sin(nlat)*sin(decl2) + cos(nlat)*cos(decl2)*cos(lha); |
| 53 | el = atan2(sel, pyth(sel)); |
| 54 | saz = sin(lha)*cos(decl2); |
| 55 | caz = cos(nlat)*sin(decl2) - sin(nlat)*cos(decl2)*cos(lha); |
| 56 | az = pi + atan2(saz, -caz); |
| 57 | |
| 58 | az /= radian; |
| 59 | el /= radian; |
| 60 | } |