sat.c 2.5 KB

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