sat.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. sat(void)
  12. {
  13. double pturbl, pturbb, pturbr;
  14. double lograd;
  15. double dele, enom, vnom, nd, sl;
  16. double capj, capn, eye, comg, omg;
  17. double sb, su, cu, u, b, up;
  18. double sd, ca, sa;
  19. ecc = .0558900 - .000347*capt;
  20. incl = 2.49256 - .0044*capt;
  21. node = 112.78364 + .87306*capt;
  22. argp = 91.08897 + 1.95917*capt;
  23. mrad = 9.538843;
  24. anom = 175.47630 + .03345972*eday - .56527*capt;
  25. motion = 120.4550/3600.;
  26. incl *= radian;
  27. node *= radian;
  28. argp *= radian;
  29. anom = fmod(anom, 360.)*radian;
  30. enom = anom + ecc*sin(anom);
  31. do {
  32. dele = (anom - enom + ecc * sin(enom)) /
  33. (1. - ecc*cos(enom));
  34. enom += dele;
  35. } while(fabs(dele) > converge);
  36. vnom = 2.*atan2(sqrt((1.+ecc)/(1.-ecc))*sin(enom/2.),
  37. cos(enom/2.));
  38. rad = mrad*(1. - ecc*cos(enom));
  39. lambda = vnom + argp;
  40. pturbl = 0.;
  41. lambda += pturbl*radsec;
  42. pturbb = 0.;
  43. pturbr = 0.;
  44. /*
  45. * reduce to the ecliptic
  46. */
  47. nd = lambda - node;
  48. lambda = node + atan2(sin(nd)*cos(incl),cos(nd));
  49. sl = sin(incl)*sin(nd) + pturbb*radsec;
  50. beta = atan2(sl, pyth(sl));
  51. lograd = pturbr*2.30258509;
  52. rad *= 1. + lograd;
  53. lambda -= 1185.*radsec;
  54. beta -= 51.*radsec;
  55. motion *= radian*mrad*mrad/(rad*rad);
  56. semi = 83.33;
  57. /*
  58. * here begins the computation of magnitude
  59. * first find the geocentric equatorial coordinates of Saturn
  60. */
  61. sd = rad*(cos(beta)*sin(lambda)*sin(obliq) +
  62. sin(beta)*cos(obliq));
  63. sa = rad*(cos(beta)*sin(lambda)*cos(obliq) -
  64. sin(beta)*sin(obliq));
  65. ca = rad*cos(beta)*cos(lambda);
  66. sd += zms;
  67. sa += yms;
  68. ca += xms;
  69. alpha = atan2(sa,ca);
  70. delta = atan2(sd,sqrt(sa*sa+ca*ca));
  71. /*
  72. * here are the necessary elements of Saturn's rings
  73. * cf. Exp. Supp. p. 363ff.
  74. */
  75. capj = 6.9056 - 0.4322*capt;
  76. capn = 126.3615 + 3.9894*capt + 0.2403*capt2;
  77. eye = 28.0743 - 0.0128*capt;
  78. comg = 168.1179 + 1.3936*capt;
  79. omg = 42.9236 - 2.7390*capt - 0.2344*capt2;
  80. capj *= radian;
  81. capn *= radian;
  82. eye *= radian;
  83. comg *= radian;
  84. omg *= radian;
  85. /*
  86. * now find saturnicentric ring-plane coords of the earth
  87. */
  88. sb = sin(capj)*cos(delta)*sin(alpha-capn) -
  89. cos(capj)*sin(delta);
  90. su = cos(capj)*cos(delta)*sin(alpha-capn) +
  91. sin(capj)*sin(delta);
  92. cu = cos(delta)*cos(alpha-capn);
  93. u = atan2(su,cu);
  94. b = atan2(sb,sqrt(su*su+cu*cu));
  95. /*
  96. * and then the saturnicentric ring-plane coords of the sun
  97. */
  98. su = sin(eye)*sin(beta) +
  99. cos(eye)*cos(beta)*sin(lambda-comg);
  100. cu = cos(beta)*cos(lambda-comg);
  101. up = atan2(su,cu);
  102. /*
  103. * at last, the magnitude
  104. */
  105. sb = sin(b);
  106. mag = -8.68 +2.52*fabs(up+omg-u)-
  107. 2.60*fabs(sb) + 1.25*(sb*sb);
  108. helio();
  109. geo();
  110. }