uran.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. static double elem[] =
  11. {
  12. 36525.0, // [0] eday of epoc
  13. 19.19126393, // [1] semi major axis (au)
  14. 0.04716771, // [2] eccentricity
  15. 0.76986, // [3] inclination (deg)
  16. 74.22988, // [4] longitude of the ascending node (deg)
  17. 170.96424, // [5] longitude of perihelion (deg)
  18. 313.23218, // [6] mean longitude (deg)
  19. 0.00152025, // [1+6] (au/julian century)
  20. -0.00019150, // [2+6] (e/julian century)
  21. -2.09, // [3+6] (arcsec/julian century)
  22. -1681.40, // [4+6] (arcsec/julian century)
  23. 1312.56, // [5+6] (arcsec/julian century)
  24. 1542547.79, // [6+6] (arcsec/julian century)
  25. };
  26. void
  27. uran(void)
  28. {
  29. double pturbl, pturbb, pturbr;
  30. double lograd;
  31. double dele, enom, vnom, nd, sl;
  32. double capj, capn, eye, comg, omg;
  33. double sb, su, cu, u, b, up;
  34. double sd, ca, sa;
  35. double cy;
  36. cy = (eday - elem[0]) / 36525.; // per julian century
  37. mrad = elem[1] + elem[1+6]*cy;
  38. ecc = elem[2] + elem[2+6]*cy;
  39. cy = cy / 3600; // arcsec/deg per julian century
  40. incl = elem[3] + elem[3+6]*cy;
  41. node = elem[4] + elem[4+6]*cy;
  42. argp = elem[5] + elem[5+6]*cy;
  43. anom = elem[6] + elem[6+6]*cy - argp;
  44. motion = elem[6+6] / 36525. / 3600;
  45. incl *= radian;
  46. node *= radian;
  47. argp *= radian;
  48. anom = fmod(anom,360.)*radian;
  49. enom = anom + ecc*sin(anom);
  50. do {
  51. dele = (anom - enom + ecc * sin(enom)) /
  52. (1. - ecc*cos(enom));
  53. enom += dele;
  54. } while(fabs(dele) > converge);
  55. vnom = 2.*atan2(sqrt((1.+ecc)/(1.-ecc))*sin(enom/2.),
  56. cos(enom/2.));
  57. rad = mrad*(1. - ecc*cos(enom));
  58. lambda = vnom + argp;
  59. pturbl = 0.;
  60. lambda += pturbl*radsec;
  61. pturbb = 0.;
  62. pturbr = 0.;
  63. /*
  64. * reduce to the ecliptic
  65. */
  66. nd = lambda - node;
  67. lambda = node + atan2(sin(nd)*cos(incl),cos(nd));
  68. sl = sin(incl)*sin(nd) + pturbb*radsec;
  69. beta = atan2(sl, pyth(sl));
  70. lograd = pturbr*2.30258509;
  71. rad *= 1. + lograd;
  72. lambda -= 1185.*radsec;
  73. beta -= 51.*radsec;
  74. motion *= radian*mrad*mrad/(rad*rad);
  75. semi = 83.33;
  76. /*
  77. * here begins the computation of magnitude
  78. * first find the geocentric equatorial coordinates of Saturn
  79. */
  80. sd = rad*(cos(beta)*sin(lambda)*sin(obliq) +
  81. sin(beta)*cos(obliq));
  82. sa = rad*(cos(beta)*sin(lambda)*cos(obliq) -
  83. sin(beta)*sin(obliq));
  84. ca = rad*cos(beta)*cos(lambda);
  85. sd += zms;
  86. sa += yms;
  87. ca += xms;
  88. alpha = atan2(sa,ca);
  89. delta = atan2(sd,sqrt(sa*sa+ca*ca));
  90. /*
  91. * here are the necessary elements of Saturn's rings
  92. * cf. Exp. Supp. p. 363ff.
  93. */
  94. capj = 6.9056 - 0.4322*capt;
  95. capn = 126.3615 + 3.9894*capt + 0.2403*capt2;
  96. eye = 28.0743 - 0.0128*capt;
  97. comg = 168.1179 + 1.3936*capt;
  98. omg = 42.9236 - 2.7390*capt - 0.2344*capt2;
  99. capj *= radian;
  100. capn *= radian;
  101. eye *= radian;
  102. comg *= radian;
  103. omg *= radian;
  104. /*
  105. * now find saturnicentric ring-plane coords of the earth
  106. */
  107. sb = sin(capj)*cos(delta)*sin(alpha-capn) -
  108. cos(capj)*sin(delta);
  109. su = cos(capj)*cos(delta)*sin(alpha-capn) +
  110. sin(capj)*sin(delta);
  111. cu = cos(delta)*cos(alpha-capn);
  112. u = atan2(su,cu);
  113. b = atan2(sb,sqrt(su*su+cu*cu));
  114. /*
  115. * and then the saturnicentric ring-plane coords of the sun
  116. */
  117. su = sin(eye)*sin(beta) +
  118. cos(eye)*cos(beta)*sin(lambda-comg);
  119. cu = cos(beta)*cos(lambda-comg);
  120. up = atan2(su,cu);
  121. /*
  122. * at last, the magnitude
  123. */
  124. sb = sin(b);
  125. mag = -8.68 +2.52*fabs(up+omg-u)-
  126. 2.60*fabs(sb) + 1.25*(sb*sb);
  127. helio();
  128. geo();
  129. }