search.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #include "astro.h"
  2. char* solstr[] =
  3. {
  4. "Fall equinox",
  5. "Winter solstice",
  6. "Spring equinox",
  7. "Summer solstice",
  8. };
  9. struct
  10. {
  11. double beta;
  12. int rta;
  13. int dec;
  14. char *betstr;
  15. } bettab[] =
  16. {
  17. -1.3572, 231, 50, "Quadrantid",
  18. 0.7620, 336, 0, "Eta aquarid",
  19. 1.5497, 260, -20, "Ophiuchid",
  20. 2.1324, 315, -15, "Capricornid",
  21. 2.1991, 339, -17, "Delta aquarid",
  22. 2.2158, 340, -30, "Pisces australid",
  23. 2.4331, 46, 58, "Perseid",
  24. -2.6578, 95, 15, "Orionid",
  25. -1.8678, 15, -55, "Phoenicid",
  26. -1.7260, 113, 32, "Geminid",
  27. 0
  28. };
  29. void
  30. search(void)
  31. {
  32. Obj2 *p, *q;
  33. int i, j;
  34. double t;
  35. for(i=0; objlst[i]; i++) {
  36. p = objlst[i];
  37. if(p == &oshad)
  38. continue;
  39. t = rise(p, -.833);
  40. if(t >= 0.)
  41. event("%s rises at ", p->name, "", t,
  42. i==0? PTIME: PTIME|DARK);
  43. t = set(p, -.833);
  44. if(t >= 0.)
  45. event("%s sets at ", p->name, "", t,
  46. i==0? PTIME: PTIME|DARK);
  47. if(p == &osun) {
  48. for(j=0; j<4; j++) {
  49. t = solstice(j);
  50. if(t >= 0)
  51. event("%s at ", solstr[j], "", t,
  52. SIGNIF|PTIME);
  53. }
  54. for(j=0; bettab[j].beta!=0; j++) {
  55. t = betcross(bettab[j].beta);
  56. if(t >= 0)
  57. event("%s meeteeor shouwer",
  58. bettab[j].betstr, "", t, SIGNIF);
  59. }
  60. t = rise(p, -18);
  61. if(t >= 0)
  62. event("Twilight starts at ", "", "", t, PTIME);
  63. t = set(p, -18);
  64. if(t >= 0)
  65. event("Twilight ends at ", "", "", t, PTIME);
  66. }
  67. if(p == &omoon)
  68. for(j=0; j<NPTS; j++) {
  69. if(p->point[j].mag > .75 && p->point[j+1].mag < .25)
  70. event("New moon", "", "", 0, 0);
  71. if(p->point[j].mag <= .25 && p->point[j+1].mag > .25)
  72. event("First quarter moon", "", "", 0, 0);
  73. if(p->point[j].mag <= .50 && p->point[j+1].mag > .50)
  74. event("Full moon", "", "", 0, 0);
  75. if(p->point[j].mag <= .75 && p->point[j+1].mag > .75)
  76. event("Last quarter moon", "", "", 0, 0);
  77. }
  78. if(p == &omerc || p == &ovenus) {
  79. t = melong(p);
  80. if(t >= 0) {
  81. t = rise(p, 0) - rise(&osun, 0);
  82. if(t < 0)
  83. t += NPTS;
  84. if(t > NPTS)
  85. t -= NPTS;
  86. if(t > NPTS/2)
  87. event("Morning elongation of %s", p->name,
  88. "", 0, SIGNIF);
  89. else
  90. event("Evening elongation of %s", p->name,
  91. "", 0, SIGNIF);
  92. }
  93. }
  94. for(j=i; objlst[j]; j++) {
  95. if(i == j)
  96. continue;
  97. q = objlst[j];
  98. if(p == &omoon || q == &omoon) {
  99. occult(p, q, 0);
  100. if(occ.t3 < 0)
  101. continue;
  102. if(p == &osun || q == &oshad) {
  103. if(occ.t1 >= 0)
  104. event("Partial eclipse of %s begins at ", p->name, "",
  105. occ.t1, SIGNIF|PTIME);
  106. if(occ.t2 >= 0)
  107. event("Total eclipse of %s begins at ", p->name, "",
  108. occ.t2, SIGNIF|PTIME);
  109. if(occ.t4 >= 0)
  110. event("Total eclipse of %s ends at ", p->name, "",
  111. occ.t4, SIGNIF|PTIME);
  112. if(occ.t5 >= 0)
  113. event("Partial eclipse of %s ends at ", p->name, "",
  114. occ.t5, SIGNIF|PTIME);
  115. } else {
  116. if(occ.t1 >= 0)
  117. event("Occultation of %s begins at ", q->name, "",
  118. occ.t1, SIGNIF|PTIME);
  119. if(occ.t5 >= 0)
  120. event("Occultation of %s ends at ", q->name, "",
  121. occ.t5, SIGNIF|PTIME);
  122. }
  123. continue;
  124. }
  125. if(p == &osun) {
  126. if(q != &omerc && q != &ovenus)
  127. continue;
  128. occult(p, q, -1);
  129. if(occ.t3 >= 0.) {
  130. if(occ.t1 >= 0)
  131. event("Transit of %s begins at ", q->name, "",
  132. occ.t1, SIGNIF|LIGHT|PTIME);
  133. if(occ.t5 >= 0)
  134. event("Transit of %s ends at ", q->name, "",
  135. occ.t5, SIGNIF|LIGHT|PTIME);
  136. }
  137. continue;
  138. }
  139. t = dist(&p->point[0], &q->point[0]);
  140. if(t > 5000)
  141. continue;
  142. event("%s is in the house of %s",
  143. p->name, q->name, 0, 0);
  144. }
  145. }
  146. if(flags['o'])
  147. stars();
  148. if(flags['a'])
  149. satels();
  150. evflush();
  151. }