geo.c 1.1 KB

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