mars.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "astro.h"
  10. void
  11. mars(void)
  12. {
  13. double pturbl, pturbb, pturbr;
  14. double lograd;
  15. double dele, enom, vnom, nd, sl;
  16. double lsun, elong, ci, dlong;
  17. ecc = .09331290 + .000092064*capt;
  18. incl = 1.850333 - 6.75e-4*capt;
  19. node = 48.786442 + .770992*capt;
  20. argp = 334.218203 + 1.840758*capt + 1.30e-4*capt2;
  21. mrad = 1.5236915;
  22. anom = 319.529425 + .5240207666*eday + 1.808e-4*capt2;
  23. motion = 0.5240711638;
  24. incl = incl*radian;
  25. node = node*radian;
  26. argp = argp*radian;
  27. anom = fmod(anom,360.)*radian;
  28. enom = anom + ecc*sin(anom);
  29. do {
  30. dele = (anom - enom + ecc * sin(enom)) /
  31. (1. - ecc*cos(enom));
  32. enom += dele;
  33. } while(fabs(dele) > converge);
  34. vnom = 2.*atan2(sqrt((1.+ecc)/(1.-ecc))*sin(enom/2.),cos(enom/2.));
  35. rad = mrad*(1. - ecc*cos(enom));
  36. lambda = vnom + argp;
  37. pturbl = 0.;
  38. lambda = lambda + pturbl*radsec;
  39. pturbb = 0.;
  40. pturbr = 0.;
  41. /*
  42. * reduce to the ecliptic
  43. */
  44. nd = lambda - node;
  45. lambda = node + atan2(sin(nd)*cos(incl),cos(nd));
  46. sl = sin(incl)*sin(nd) + pturbb*radsec;
  47. beta = atan2(sl, pyth(sl));
  48. lograd = pturbr*2.30258509;
  49. rad *= 1. + lograd;
  50. motion *= radian*mrad*mrad/(rad*rad);
  51. semi = 4.68;
  52. lsun = 99.696678 + 0.9856473354*eday;
  53. lsun *= radian;
  54. elong = lambda - lsun;
  55. ci = (rad - cos(elong))/sqrt(1. + rad*rad - 2.*rad*cos(elong));
  56. dlong = atan2(pyth(ci), ci)/radian;
  57. mag = -1.30 + .01486*dlong;
  58. helio();
  59. geo();
  60. }