init.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. Obj2* objlst[] =
  11. {
  12. &osun,
  13. &omoon,
  14. &oshad,
  15. &omerc,
  16. &ovenus,
  17. &omars,
  18. &ojup,
  19. &osat,
  20. &ouran,
  21. &onept,
  22. &oplut,
  23. &ocomet,
  24. 0,
  25. };
  26. struct idata
  27. {
  28. char* name;
  29. char* name1;
  30. void (*obj)(void);
  31. } idata[] =
  32. {
  33. "The sun", "sun", fsun,
  34. "The moon", "moon", moon,
  35. "The shadow", "shadow", shad,
  36. "Mercury", "mercury", merc,
  37. "Venus", "venus", venus,
  38. "Mars", "mars", mars,
  39. "Jupiter", "jupiter", jup,
  40. "Saturn", "saturn", sat,
  41. "Uranus", "uranus", uran,
  42. "Neptune", "neptune", nept,
  43. "Pluto", "pluto", plut,
  44. "Comet", "comet", comet,
  45. };
  46. void
  47. init(void)
  48. {
  49. Obj2 *q;
  50. int i;
  51. glat = nlat - (692.74*radsec)*sin(2.*nlat)
  52. + (1.16*radsec)*sin(4.*nlat);
  53. erad = .99832707e0 + .00167644e0*cos(2.*nlat)
  54. - 0.352e-5*cos(4.*nlat)
  55. + 0.001e-5*cos(6.*nlat)
  56. + 0.1568e-6*elev;
  57. for(i=0; q=objlst[i]; i++) {
  58. q->name = idata[i].name;
  59. q->name1 = idata[i].name1;
  60. q->obj = idata[i].obj;
  61. }
  62. ostar.obj = fstar;
  63. ostar.name = "star";
  64. }
  65. void
  66. setime(double d)
  67. {
  68. double x, xm, ym, zm;
  69. eday = d + deltat/86400.;
  70. wlong = awlong + 15.*deltat*radsec;
  71. capt = eday/36524.220e0;
  72. capt2 = capt*capt;
  73. capt3 = capt*capt2;
  74. nutate();
  75. eday += .1;
  76. sun();
  77. srad = rad;
  78. xm = rad*cos(beta)*cos(lambda);
  79. ym = rad*cos(beta)*sin(lambda);
  80. zm = rad*sin(beta);
  81. eday -= .1;
  82. sun();
  83. xms = rad*cos(beta)*cos(lambda);
  84. yms = rad*cos(beta)*sin(lambda);
  85. zms = rad*sin(beta);
  86. x = .057756;
  87. xdot = x*(xm-xms);
  88. ydot = x*(ym-yms);
  89. zdot = x*(zm-zms);
  90. }
  91. void
  92. setobj(Obj1 *op)
  93. {
  94. Obj1 *p;
  95. p = op;
  96. p->ra = ra;
  97. p->decl2 = decl2;
  98. p->semi2 = semi2;
  99. p->az = az;
  100. p->el = el;
  101. p->mag = mag;
  102. }
  103. int32_t starsao = 0;
  104. void
  105. fstar(void)
  106. {
  107. ra = ostar.point[0].ra;
  108. decl2 = ostar.point[0].decl2;
  109. semi2 = ostar.point[0].semi2;
  110. az = ostar.point[0].az;
  111. el = ostar.point[0].el;
  112. mag = ostar.point[0].mag;
  113. }
  114. void
  115. fsun(void)
  116. {
  117. beta = 0;
  118. rad = 0;
  119. lambda = 0;
  120. motion = 0;
  121. helio();
  122. geo();
  123. seday = eday;
  124. salph = alpha;
  125. sdelt = delta;
  126. mag = lmb2;
  127. }
  128. void
  129. shad(void)
  130. {
  131. if(seday != eday)
  132. fsun();
  133. if(meday != eday)
  134. moon();
  135. alpha = fmod(salph+pi, pipi);
  136. delta = -sdelt;
  137. hp = mhp;
  138. semi = 1.0183*mhp/radsec - 969.85/srad;
  139. geo();
  140. }