home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume28 / ephem / part08 < prev    next >
Text File  |  1992-03-15  |  55KB  |  1,728 lines

  1. Newsgroups: comp.sources.misc
  2. From: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
  3. Subject:  v28i091:  ephem - an interactive astronomical ephemeris, v4.28, Part08/09
  4. Message-ID: <1992Mar10.215948.16347@sparky.imd.sterling.com>
  5. X-Md4-Signature: a86493ced0f07dfdbcc97970990b6b29
  6. Date: Tue, 10 Mar 1992 21:59:48 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
  10. Posting-number: Volume 28, Issue 91
  11. Archive-name: ephem/part08
  12. Environment: UNIX, VMS, DOS, MAC
  13. Supersedes: ephem-4.21: Volume 14, Issue 76-81
  14.  
  15. #! /bin/sh
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  19. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  20. # Contents:  Readme altj.c cal_mjd.c circum.h comet.c moon.c pelement.c
  21. #   precess.c refract.c riset.c screen.h time.c
  22. # Wrapped by kent@sparky on Tue Mar 10 14:34:09 1992
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 8 (of 9)."'
  26. if test -f 'Readme' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'Readme'\"
  28. else
  29.   echo shar: Extracting \"'Readme'\" \(5311 characters\)
  30.   sed "s/^X//" >'Readme' <<'END_OF_FILE'
  31. XGeneral Notes for ephem:
  32. X
  33. X1) Start by reading the generic-printer-ready manual in Man.txt.
  34. X
  35. XIf you have source, here is how you build ephem:
  36. X
  37. X1) io.c:
  38. X   define UNIX, VMS or TURBO_C in io.c depending on your system. Note that
  39. X   TURBO_C also seems to work ok with Microsoft and Lattice C too but these
  40. X   have not been tested recently. Note also that the VMS C compiler defines VMS
  41. X   automatically so you don't really have to #define it.
  42. X
  43. X   Also in io.c and if you use UNIX, you have four choices of methods for doing
  44. X   non-blocking reads and two choices for controlling tty modes. #define one
  45. X   of USE_FIONREAD, USE_NDELAY, USE_ATTSELECT and USE_BSDSELECT and one of
  46. X   USE_TERMIO and USE_SGTTY.
  47. X
  48. X   And also in io.c MSDOS users may do cursor control with direct BIOS calls
  49. X   (the default), or with ANSI.SYS by defining USE_ANSISYS.
  50. X
  51. X2) time.c:
  52. X   Select from two methods of dealing with time from the operating system
  53. X   with the TZA/TZB defines in time.c. If you get link undefines related to
  54. X   time functions try changing to the other form.
  55. X
  56. X   On Sun systems running OS 4.0.3 (or BSD 4.3) or Apollo SR 10.1 use TZB and
  57. X   change <time.h> to <sys/time.h>.
  58. X
  59. X   For VMS, since it does not support time zone info, do NOT #define EITHER
  60. X   of TZA or TZB. This will have the effect of leaving the time zone unchanged
  61. X   whenever you set the time via the "Now" option. (This is taken care of
  62. X   automatically in time.c by #undef'ining TZA and TZB if VMS is defined.)
  63. X
  64. X3) mainmenu.c:
  65. X   if you are compiling for an IBM-PC then #define PC_GRAPHICS for a nicer
  66. X   looking way to draw the screen boundry lines using character graphics.
  67. X
  68. X4) sel_fld.c:
  69. X   if your runtime library supports the system() function (to run a shell
  70. X   command) then leave #define BANG in sel_fld.c, else undefine it. When
  71. X   defined, this will allow you to jump out of ephem and run any command,
  72. X   then resume where you left off.
  73. X
  74. X5) beware that I have not used string.h or strings.h. if your library's
  75. X   strlen() and str.*cmp() functions don't return int (such as long), then you
  76. X   will have to hand add string.h or your own extern declarations. I have
  77. X   included all the necessary declarations for the functions that return
  78. X   (char *) such as strcpy(), etc, though.
  79. X
  80. X6) main.c calls sleep() which is not in some IBM-PC runtime C libraries. You
  81. X   might kludge up your own call that does a cpu countdown loop. The accuracy
  82. X   will only effect the Pause feature, not ephem's actual time mechanisms.
  83. X
  84. X7) Ephem can now be built by simply compiling all the .c files and linking them
  85. X   all together. On Unix systems, you must also link with the termcap library
  86. X   (-ltermcap) and possibly the auxiliary math library (-lm) if your default C
  87. X   library does not include all the required transcendental functions. At the
  88. X   end of this file I have included a VMS build script for those building
  89. X   ephem on a that system.
  90. X
  91. XThe following files are pretty much just pure transliterations from BASIC
  92. Xinto C from machine-readable copies of the programs in Duffett-Smith's book.
  93. XThey have nothing to do with the rest of ephem so they may be used for
  94. Xcompletely different applications if so desired.
  95. X
  96. X   aa_hadec.c anomaly.c astro.h cal_mjd.c comet.c eq_ecl.c moon.c moonnf.c
  97. X   nutation.c obliq.c parallax.c pelement.c plans.c reduce.c refract.c
  98. X   sex_dec.c sun.c utc_gst.c
  99. X
  100. XIf you would like to gut ephem for just its astronomical functionality,
  101. Xstart with body_cir().
  102. X
  103. X$!========================================================================
  104. X$!
  105. X$! Name      : BUILD.COM
  106. X$!
  107. X$! Purpose   : compile and link ephem under VMS
  108. X$!
  109. X$! Arguments : P1/P2 = DEBUG: compile with DEBUG info
  110. X$!             P1/P2 = LINK : link only
  111. X$!             P1    = nn   : start compiling at list element "nn" (0-36)
  112. X$!
  113. X$! Created  23-MAR-1990   Karsten Spang
  114. X$! Modified 31-AUG-1990   Rick Dyson
  115. X$!                        added listing to FILES for v4.19
  116. X$!                        added P1 = nn option
  117. X$!
  118. X$!========================================================================
  119. X$   VERIFY = F$Verify (0)
  120. X$   On ERROR     Then GoTo EXIT
  121. X$   On CONTROL_Y Then GoTo EXIT
  122. X$   If P1 .eqs. "DEBUG" .or. P2 .eqs. "DEBUG"
  123. X$       Then
  124. X$           CC      := Cc /Debug /NoOptimize /NoList
  125. X$           LINK    := Link /Debug /NoMap
  126. X$       Else
  127. X$           CC      := Cc /NoList
  128. X$           LINK    := Link /NoMap
  129. X$   EndIf
  130. X$   FILES = "MAIN,AA_HADEC,ALTJ,ALTMENUS,ANOMALY,CAL_MJD,CIRCUM,COMET,"+ -
  131. X        "COMPILER,CONSTEL,EQ_ECL,FLOG,FORMATS,IO,LISTING,MAINMENU,"+ -
  132. X    "MOON,MOONNF,NUTATION,OBJX,OBLIQ,PARALLAX,PELEMENT,PLANS,PLOT,"+ -
  133. X        "POPUP,PRECESS,REDUCE,REFRACT,RISET,RISET_C,SEL_FLD,SEX_DEC,SRCH,"+ -
  134. X        "SUN,TIME,UTC_GST,VERSION,WATCH"
  135. X$   If P1 .eqs. "LINK" .or. P2 .eqs. "LINK" Then GoTo LINK
  136. X$   FILE_NUM = F$Integer (P1)
  137. X$   If (FILE_NUM .ge. 37 .or. FILE_NUM .lt. 0) Then FILE_NUM = 0
  138. X$COMPILE_LOOP:
  139. X$   FILE = F$Element (FILE_NUM, "," ,FILES)
  140. X$   If FILE .eqs. "," Then GoTo COMPILE_END
  141. X$   Write Sys$Output "Compiling file number ''FILE_NUM' = ''FILE' ..."
  142. X$   CC 'FILE'
  143. X$   FILE_NUM = FILE_NUM + 1
  144. X$   GoTo COMPILE_LOOP
  145. X$COMPILE_END:
  146. X$LINK:
  147. X$   Write Sys$Output "Linking ephem now...^G"
  148. X$   LINK /Exe = EPHEM 'FILES',Sys$Input/Opt
  149. XSys$Library:VAXCRTL/Share
  150. X$EXIT:
  151. X$   Set NoOn
  152. X$   Purge *.OBJ,*.EXE
  153. X$   If VERIFY Then Set Verify
  154. X$   Exit
  155. END_OF_FILE
  156.   if test 5311 -ne `wc -c <'Readme'`; then
  157.     echo shar: \"'Readme'\" unpacked with wrong size!
  158.   fi
  159.   # end of 'Readme'
  160. fi
  161. if test -f 'altj.c' -a "${1}" != "-c" ; then 
  162.   echo shar: Will not clobber existing file \"'altj.c'\"
  163. else
  164.   echo shar: Extracting \"'altj.c'\" \(6077 characters\)
  165.   sed "s/^X//" >'altj.c' <<'END_OF_FILE'
  166. X/* management and computional support for jupiter's detail menu.
  167. X */
  168. X
  169. X#include <math.h>
  170. X#include "astro.h"
  171. X#include "circum.h"
  172. X#include "screen.h"
  173. X
  174. Xaltj_labels()
  175. X{
  176. X    static char grs[] = "(GRS is at approximately 30 degs in System II)";
  177. X
  178. X    f_string (R_ALTM, C_ALTMV, "  Jupiter Aux");
  179. X
  180. X    f_string (R_JCML, 6, "Central Meridian Longitude (degs):");
  181. X    f_string (R_JCML, 51, "(Sys I)");
  182. X    f_string (R_JCML, 68, "(Sys II)");
  183. X    f_string (R_JCML+1, (NC-sizeof(grs))/2, grs);
  184. X
  185. X    f_string (R_IO,        C_JMNAMES,    "I   Io");
  186. X    f_string (R_EUROPA,    C_JMNAMES,    "II  Europa");
  187. X    f_string (R_GANYMEDE,    C_JMNAMES,    "III Ganymede");
  188. X    f_string (R_CALLISTO,    C_JMNAMES,    "IV  Callisto");
  189. X    f_string (R_JCOLHDNGS-1,C_JMY-2,    "Jupiter Radii");
  190. X    f_string (R_JCOLHDNGS,    C_JMX+1,    "X (+E)");
  191. X    f_string (R_JCOLHDNGS,    C_JMY+1,    "Y (+S)");
  192. X    f_string (R_JCOLHDNGS,    C_JMZ-2,    "Z (+towards)");
  193. X    f_string (R_JMAP+1,    2,        "West");
  194. X    f_string (R_JMAP+1,    NC-5,        "East");
  195. X}
  196. X
  197. X/* display jupiter's details. */
  198. X/* ARGSUSED */
  199. Xaltj_display (force, np)
  200. Xint force;    /* whether to print for sure or only if things have changed */
  201. XNow *np;
  202. X{
  203. X#define    NJM    5    /* number of moons, plus + for Jupiter itself */
  204. X#define    NORM    26.6    /* max callisto orbit radius; used to normalize */
  205. X    static char fmt[] = "%7.3f";
  206. X    struct moonxlocs {
  207. X        double x;
  208. X        char mid;
  209. X    } raw_ml[NJM], sorted_ml[NJM];
  210. X    int nml;    /* number of sorted_ml[] elements in use */
  211. X    char buf[NC];
  212. X    double iy, ey, gy, cy;
  213. X    double iz, ez, gz, cz;
  214. X    double sIcml, sIIcml;
  215. X    int i;
  216. X
  217. X    /* compute jupiter info.
  218. X     * put moons' x loc into raw_ml[] so it can be sorted for graphic.
  219. X     */
  220. X    jupinfo (mjd, &raw_ml[0].x, &raw_ml[1].x, &raw_ml[2].x, &raw_ml[3].x,
  221. X            &iy, &ey, &gy, &cy, &iz, &ez, &gz, &cz, &sIcml, &sIIcml);
  222. X
  223. X    f_double (R_JCML, C_JCMLSI, fmt, sIcml);
  224. X    f_double (R_JCML, C_JCMLSII, fmt, sIIcml);
  225. X    f_double (R_IO, C_JMX, fmt, raw_ml[0].x);
  226. X    f_double (R_EUROPA, C_JMX, fmt, raw_ml[1].x);
  227. X    f_double (R_GANYMEDE, C_JMX, fmt, raw_ml[2].x);
  228. X    f_double (R_CALLISTO, C_JMX, fmt, raw_ml[3].x);
  229. X    f_double (R_IO, C_JMY, fmt, iy);
  230. X    f_double (R_EUROPA, C_JMY, fmt, ey);
  231. X    f_double (R_GANYMEDE, C_JMY, fmt, gy);
  232. X    f_double (R_CALLISTO, C_JMY, fmt, cy);
  233. X    f_double (R_IO, C_JMZ, fmt, iz);
  234. X    f_double (R_EUROPA, C_JMZ, fmt, ez);
  235. X    f_double (R_GANYMEDE, C_JMZ, fmt, gz);
  236. X    f_double (R_CALLISTO, C_JMZ, fmt, cz);
  237. X
  238. X    raw_ml[0].mid = 'I';
  239. X    raw_ml[1].mid = 'E';
  240. X    raw_ml[2].mid = 'G';
  241. X    raw_ml[3].mid = 'C';
  242. X    raw_ml[4].x = 0.0;
  243. X    raw_ml[4].mid = 'J';
  244. X
  245. X    /* insert in increasing order into sorted_ml[]
  246. X     */
  247. X    nml = 0;
  248. X    for (i = 0; i < NJM; i++) {
  249. X        int j;
  250. X        /* exit loop with next sort_ml location to use at index j+1 */
  251. X        for (j = nml; --j >= 0; )
  252. X        if (raw_ml[i].x < sorted_ml[j].x)
  253. X            sorted_ml[j+1] = sorted_ml[j];
  254. X        else
  255. X            break;
  256. X        sorted_ml[j+1] = raw_ml[i];
  257. X        nml++;
  258. X    }
  259. X
  260. X    /* blank-fill and terminate buf */
  261. X    (void) sprintf (buf, "%*s", NC-1, "");
  262. X
  263. X    /* convert to screen columns, maintaining correct left-to-right
  264. X     * order based on x when there are collisions.
  265. X     */
  266. X    for (i = 0; i < NJM; i++) {
  267. X        int col = (int)(NC/2-1 + (NC/2-1)*sorted_ml[i].x/NORM + 0.5);
  268. X        while (buf[col] != ' ')
  269. X        col++;
  270. X        buf[col] = sorted_ml[i].mid;
  271. X    }
  272. X
  273. X    f_string (R_JMAP, C_JMAP, buf);
  274. X}
  275. X
  276. X#define    dsin(x)    sin(degrad(x))
  277. X#define    dcos(x)    cos(degrad(x))
  278. X
  279. X/* given a modified julian date (ie, days since Jan .5 1900), d, return x, y, z
  280. X *   location of each Galilean moon as a multiple of Jupiter's radius. on this
  281. X *   scale, Callisto is never more than 26.5593. +x is easterly, +y is
  282. X *   southerly, +z is towards earth. x and z are relative to the equator
  283. X *   of Jupiter; y is further corrected for earth's position above or below
  284. X *   this plane. also, return the system I and II central meridian longitude,
  285. X *   in degress, relative to the true disk of jupiter and corrected for light
  286. X *   travel time.
  287. X * from "Astronomical Formulae for Calculators", 2nd ed, by Jean Meeus,
  288. X *   Willmann-Bell, Richmond, Va., U.S.A. (c) 1982, chapters 35 and 36.
  289. X */
  290. Xstatic
  291. Xjupinfo (d, ix, ex, gx, cx, iy, ey, gy, cy, iz, ez, gz, cz, sIcml, sIIcml)
  292. Xdouble d;
  293. Xdouble *ix, *ex, *gx, *cx;
  294. Xdouble *iy, *ey, *gy, *cy;
  295. Xdouble *iz, *ez, *gz, *cz;
  296. Xdouble *sIcml, *sIIcml;
  297. X{
  298. X    double A, B, Del, J, K, M, N, R, V;
  299. X    double cor_u1, cor_u2, cor_u3, cor_u4;
  300. X    double solc, tmp, G, H, psi, r, r1, r2, r3, r4;
  301. X    double u1, u2, u3, u4;
  302. X    double lam, Ds;
  303. X    double z1, z2, z3,  z4;
  304. X    double De, dsinDe;
  305. X
  306. X    V = 134.63 + 0.00111587 * d;
  307. X
  308. X    M = (358.47583 + 0.98560003*d);
  309. X    N = (225.32833 + 0.0830853*d) + 0.33 * dsin (V);
  310. X
  311. X    J = 221.647 + 0.9025179*d - 0.33 * dsin(V);;
  312. X
  313. X    A = 1.916*dsin(M) + 0.02*dsin(2*M);
  314. X    B = 5.552*dsin(N) + 0.167*dsin(2*N);
  315. X    K = (J+A-B);
  316. X    R = 1.00014 - 0.01672 * dcos(M) - 0.00014 * dcos(2*M);
  317. X    r = 5.20867 - 0.25192 * dcos(N) - 0.00610 * dcos(2*N);
  318. X    Del = sqrt (R*R + r*r - 2*R*r*dcos(K));
  319. X    psi = raddeg (asin (R/Del*dsin(K)));
  320. X
  321. X    solc = (d - Del/173.);    /* speed of light correction */
  322. X    tmp = psi - B;
  323. X
  324. X    u1 = 84.5506 + 203.4058630 * solc + tmp;
  325. X    u2 = 41.5015 + 101.2916323 * solc + tmp;
  326. X    u3 = 109.9770 + 50.2345169 * solc + tmp;
  327. X    u4 = 176.3586 + 21.4879802 * solc + tmp;
  328. X
  329. X    G = 187.3 + 50.310674 * solc;
  330. X    H = 311.1 + 21.569229 * solc;
  331. X      
  332. X    cor_u1 =  0.472 * dsin (2*(u1-u2));
  333. X    cor_u2 =  1.073 * dsin (2*(u2-u3));
  334. X    cor_u3 =  0.174 * dsin (G);
  335. X    cor_u4 =  0.845 * dsin (H);
  336. X      
  337. X    r1 = 5.9061 - 0.0244 * dcos (2*(u1-u2));
  338. X    r2 = 9.3972 - 0.0889 * dcos (2*(u2-u3));
  339. X    r3 = 14.9894 - 0.0227 * dcos (G);
  340. X    r4 = 26.3649 - 0.1944 * dcos (H);
  341. X
  342. X    *ix = -r1 * dsin (u1+cor_u1);
  343. X    *ex = -r2 * dsin (u2+cor_u2);
  344. X    *gx = -r3 * dsin (u3+cor_u3);
  345. X    *cx = -r4 * dsin (u4+cor_u4);
  346. X
  347. X    lam = 238.05 + 0.083091*d + 0.33*dsin(V) + B;
  348. X    Ds = 3.07*dsin(lam + 44.5);
  349. X    De = Ds - 2.15*dsin(psi)*dcos(lam+24.)
  350. X        - 1.31*(r-Del)/Del*dsin(lam-99.4);
  351. X    dsinDe = dsin(De);
  352. X
  353. X    z1 = r1 * dcos(u1+cor_u1);
  354. X    z2 = r2 * dcos(u2+cor_u2);
  355. X    z3 = r3 * dcos(u3+cor_u3);
  356. X    z4 = r4 * dcos(u4+cor_u4);
  357. X
  358. X    *iy = z1*dsinDe;
  359. X    *ey = z2*dsinDe;
  360. X    *gy = z3*dsinDe;
  361. X    *cy = z4*dsinDe;
  362. X
  363. X    *iz = z1;
  364. X    *ez = z2;
  365. X    *gz = z3;
  366. X    *cz = z4;
  367. X
  368. X    *sIcml  = 268.28 + 877.8169088*(d - Del/173) + psi - B;
  369. X    range (sIcml, 360.0);
  370. X    *sIIcml = 290.28 + 870.1869088*(d - Del/173) + psi - B;
  371. X    range (sIIcml, 360.0);
  372. X}
  373. END_OF_FILE
  374.   if test 6077 -ne `wc -c <'altj.c'`; then
  375.     echo shar: \"'altj.c'\" unpacked with wrong size!
  376.   fi
  377.   # end of 'altj.c'
  378. fi
  379. if test -f 'cal_mjd.c' -a "${1}" != "-c" ; then 
  380.   echo shar: Will not clobber existing file \"'cal_mjd.c'\"
  381. else
  382.   echo shar: Extracting \"'cal_mjd.c'\" \(3113 characters\)
  383.   sed "s/^X//" >'cal_mjd.c' <<'END_OF_FILE'
  384. X#include <stdio.h>
  385. X#include <math.h>
  386. X#include "astro.h"
  387. X
  388. X/* given a date in months, mn, days, dy, years, yr,
  389. X * return the modified Julian date (number of days elapsed since 1900 jan 0.5),
  390. X * *mjd.
  391. X */
  392. Xcal_mjd (mn, dy, yr, mjd)
  393. Xint mn, yr;
  394. Xdouble dy;
  395. Xdouble *mjd;
  396. X{
  397. X    int b, d, m, y;
  398. X    long c;
  399. X
  400. X    m = mn;
  401. X    y = (yr < 0) ? yr + 1 : yr;
  402. X    if (mn < 3) {
  403. X        m += 12;
  404. X        y -= 1;
  405. X    }
  406. X
  407. X    if (yr < 1582 || yr == 1582 && (mn < 10 || mn == 10 && dy < 15)) 
  408. X        b = 0;
  409. X    else {
  410. X        int a;
  411. X        a = y/100;
  412. X        b = 2 - a + a/4;
  413. X    }
  414. X
  415. X    if (y < 0)
  416. X        c = (long)((365.25*y) - 0.75) - 694025L;
  417. X    else
  418. X        c = (long)(365.25*y) - 694025L;
  419. X
  420. X    d = 30.6001*(m+1);
  421. X
  422. X    *mjd = b + c + d + dy - 0.5;
  423. X}
  424. X
  425. X/* given the modified Julian date (number of days elapsed since 1900 jan 0.5,),
  426. X * mjd, return the calendar date in months, *mn, days, *dy, and years, *yr.
  427. X */
  428. Xmjd_cal (mjd, mn, dy, yr)
  429. Xdouble mjd;
  430. Xint *mn, *yr;
  431. Xdouble *dy;
  432. X{
  433. X    double d, f;
  434. X    double i, a, b, ce, g;
  435. X
  436. X    d = mjd + 0.5;
  437. X    i = floor(d);
  438. X    f = d-i;
  439. X    if (f == 1) {
  440. X        f = 0;
  441. X        i += 1;
  442. X    }
  443. X
  444. X    if (i > -115860.0) {
  445. X        a = floor((i/36524.25)+.9983573)+14;
  446. X        i += 1 + a - floor(a/4.0);
  447. X    }
  448. X
  449. X    b = floor((i/365.25)+.802601);
  450. X    ce = i - floor((365.25*b)+.750001)+416;
  451. X    g = floor(ce/30.6001);
  452. X    *mn = g - 1;
  453. X    *dy = ce - floor(30.6001*g)+f;
  454. X    *yr = b + 1899;
  455. X
  456. X    if (g > 13.5)
  457. X        *mn = g - 13;
  458. X    if (*mn < 2.5)
  459. X        *yr = b + 1900;
  460. X    if (*yr < 1)
  461. X        *yr -= 1;
  462. X}
  463. X
  464. X/* given an mjd, set *dow to 0..6 according to which dayof the week it falls
  465. X * on (0=sunday) or set it to -1 if can't figure it out.
  466. X */
  467. Xmjd_dow (mjd, dow)
  468. Xdouble mjd;
  469. Xint *dow;
  470. X{
  471. X    /* cal_mjd() uses Gregorian dates on or after Oct 15, 1582.
  472. X     * (Pope Gregory XIII dropped 10 days, Oct 5..14, and improved the leap-
  473. X     * year algorithm). however, Great Britian and the colonies did not
  474. X     * adopt it until Sept 14, 1752 (they dropped 11 days, Sept 3-13,
  475. X     * due to additional accumulated error). leap years before 1752 thus
  476. X     * can not easily be accounted for from the cal_mjd() number...
  477. X     */
  478. X    if (mjd < -53798.5) {
  479. X        /* pre sept 14, 1752 too hard to correct */
  480. X        *dow = -1;
  481. X        return;
  482. X    }
  483. X    *dow = ((long)floor(mjd-.5) + 1) % 7;/* 1/1/1900 (mjd 0.5) is a Monday*/
  484. X    if (*dow < 0)
  485. X        *dow += 7;
  486. X}
  487. X
  488. X/* given a mjd, return the the number of days in the month.  */
  489. Xmjd_dpm (mjd, ndays)
  490. Xdouble mjd;
  491. Xint *ndays;
  492. X{
  493. X    static short dpm[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  494. X    int m, y;
  495. X    double d;
  496. X
  497. X    mjd_cal (mjd, &m, &d, &y);
  498. X    *ndays = (m==2 && ((y%4==0 && y%100!=0)||y%400==0)) ? 29 : dpm[m-1];
  499. X}
  500. X
  501. X
  502. X/* given a mjd, return the year as a double. */
  503. Xmjd_year (mjd, yr)
  504. Xdouble mjd;
  505. Xdouble *yr;
  506. X{
  507. X    int m, y;
  508. X    double d;
  509. X    double e0, e1;    /* mjd of start of this year, start of next year */
  510. X
  511. X    mjd_cal (mjd, &m, &d, &y);
  512. X    if (y == -1) y = -2;
  513. X    cal_mjd (1, 1.0, y, &e0);
  514. X    cal_mjd (1, 1.0, y+1, &e1);
  515. X    *yr = y + (mjd - e0)/(e1 - e0);
  516. X}
  517. X
  518. X/* given a decimal year, return mjd */
  519. Xyear_mjd (y, mjd)
  520. Xdouble y;
  521. Xdouble *mjd;
  522. X{
  523. X    double e0, e1;    /* mjd of start of this year, start of next year */
  524. X    int yf = floor (y);
  525. X    if (yf == -1) yf = -2;
  526. X
  527. X    cal_mjd (1, 1.0, yf, &e0);
  528. X    cal_mjd (1, 1.0, yf+1, &e1);
  529. X    *mjd = e0 + (y - yf)*(e1-e0);
  530. X}
  531. END_OF_FILE
  532.   if test 3113 -ne `wc -c <'cal_mjd.c'`; then
  533.     echo shar: \"'cal_mjd.c'\" unpacked with wrong size!
  534.   fi
  535.   # end of 'cal_mjd.c'
  536. fi
  537. if test -f 'circum.h' -a "${1}" != "-c" ; then 
  538.   echo shar: Will not clobber existing file \"'circum.h'\"
  539. else
  540.   echo shar: Extracting \"'circum.h'\" \(2856 characters\)
  541.   sed "s/^X//" >'circum.h' <<'END_OF_FILE'
  542. X#define    SPD    (24.0*3600.0)    /* seconds per day */
  543. X
  544. X#define    EOD    (-9786)        /* special epoch flag: use epoch of date */
  545. X#define    RTC    (-1324)        /* special tminc flag: use rt clock */
  546. X#define    NOMJD    (-58631.)    /* an unlikely mjd for initing static mjd's */
  547. X#define    NOHELIO    (-2314)        /* special s_hlong flag: means it and s_hlat are
  548. X                 * undefined
  549. X                 */
  550. X
  551. X#define    STDHZN        0    /* rise/set times based on nominal conditions */
  552. X#define    ADPHZN        1    /* rise/set times based on exact current " */
  553. X#define    TWILIGHT    2    /* rise/set times for sun 18 degs below hor */
  554. X
  555. X/* info about our local observing circumstances */
  556. Xtypedef struct {
  557. X    double n_mjd;    /* modified Julian date, ie, days since
  558. X             * Jan 0.5 1900 (== 12 noon, Dec 30, 1899), utc.
  559. X             * enough precision to get well better than 1 second.
  560. X             * N.B. if not first member, must move NOMJD inits.
  561. X             */
  562. X    double n_lat;    /* latitude, >0 north, rads */
  563. X    double n_lng;    /* longitude, >0 east, rads */
  564. X    double n_tz;    /* time zone, hrs behind UTC */
  565. X    double n_temp;    /* atmospheric temp, degrees C */
  566. X    double n_pressure; /* atmospheric pressure, mBar */
  567. X    double n_height;    /* height above sea level, earth radii */
  568. X    double n_epoch;    /* desired precession display epoch as an mjd, or EOD */
  569. X    char n_tznm[4];    /* time zone name; 3 chars or less, always 0 at end */
  570. X} Now;
  571. Xextern double    mjd_day(), mjd_hr();
  572. X
  573. X/* info about where and how we see something in the sky */
  574. Xtypedef struct {
  575. X    double s_ra;    /* ra, rads (precessed to n_epoch) */
  576. X    double s_dec;    /* dec, rads (precessed to n_epoch) */
  577. X    double s_az;    /* azimuth, >0 e of n, rads */
  578. X    double s_alt;    /* altitude above topocentric horizon, rads */
  579. X    double s_sdist;    /* dist from object to sun, au */
  580. X    double s_edist;    /* dist from object to earth, au */
  581. X    double s_elong;    /* angular sep between object and sun, >0 if east */
  582. X    double s_hlong;    /* heliocentric longitude, rads */
  583. X    double s_hlat;    /* heliocentric latitude, rads */
  584. X    double s_size;    /* angular size, arc secs */
  585. X    double s_phase;    /* phase, % */
  586. X    double s_mag;    /* visual magnitude */
  587. X} Sky;
  588. X
  589. X/* flags for riset_cir() status */
  590. X#define    RS_NORISE    0x001    /* object does not rise as such today */
  591. X#define    RS_2RISES    0x002    /* object rises more than once today */
  592. X#define    RS_NOSET    0x004    /* object does not set as such today */
  593. X#define    RS_2SETS    0x008    /* object sets more than once today */
  594. X#define    RS_CIRCUMPOLAR    0x010    /* object stays up all day today */
  595. X#define    RS_2TRANS    0x020    /* transits twice in one day */
  596. X#define    RS_NEVERUP    0x040    /* object never rises today */
  597. X#define    RS_NOTRANS    0x080    /* doesn't transit today */
  598. X#define    RS_ERROR    0x100    /* can't figure out times... */
  599. X
  600. X/* shorthands for fields a Now pointer, np */
  601. X#define mjd    np->n_mjd
  602. X#define lat    np->n_lat
  603. X#define lng    np->n_lng
  604. X#define tz    np->n_tz
  605. X#define temp    np->n_temp
  606. X#define pressure np->n_pressure
  607. X#define height    np->n_height
  608. X#define epoch    np->n_epoch
  609. X#define tznm    np->n_tznm
  610. END_OF_FILE
  611.   if test 2856 -ne `wc -c <'circum.h'`; then
  612.     echo shar: \"'circum.h'\" unpacked with wrong size!
  613.   fi
  614.   # end of 'circum.h'
  615. fi
  616. if test -f 'comet.c' -a "${1}" != "-c" ; then 
  617.   echo shar: Will not clobber existing file \"'comet.c'\"
  618. else
  619.   echo shar: Extracting \"'comet.c'\" \(2390 characters\)
  620.   sed "s/^X//" >'comet.c' <<'END_OF_FILE'
  621. X#include <math.h>
  622. X#include "astro.h"
  623. X
  624. X/* given a modified Julian date, mjd, and a set of heliocentric parabolic
  625. X * orbital elements referred to the epoch of date (mjd):
  626. X *   ep:   epoch of perihelion,
  627. X *   inc:  inclination,
  628. X *   ap:   argument of perihelion (equals the longitude of perihelion minus the
  629. X *       longitude of ascending node)
  630. X *   qp:   perihelion distance,
  631. X *   om:   longitude of ascending node;
  632. X * find:
  633. X *   lpd:  heliocentric longitude, 
  634. X *   psi:  heliocentric latitude,
  635. X *   rp:   distance from the sun to the planet, 
  636. X *   rho:  distance from the Earth to the planet,
  637. X *   lam:  geocentric ecliptic longitude, 
  638. X *   bet:  geocentric ecliptic latitude,
  639. X *         none are corrected for light time, ie, they are the true values for
  640. X *       the given instant.
  641. X *
  642. X * all angles are in radians, all distances in AU.
  643. X * mutual perturbation corrections with other solar system objects are not
  644. X * applied. corrections for nutation and abberation must be made by the caller.
  645. X * The RA and DEC calculated from the fully-corrected ecliptic coordinates are
  646. X * then the apparent geocentric coordinates. Further corrections can be made,
  647. X * if required, for atmospheric refraction and geocentric parallax.
  648. X */
  649. Xcomet (mjd, ep, inc, ap, qp, om, lpd, psi, rp, rho, lam, bet)
  650. Xdouble mjd;
  651. Xdouble ep, inc, ap, qp, om;
  652. Xdouble *lpd, *psi, *rp, *rho, *lam, *bet;
  653. X{
  654. X    double w, s, s2;
  655. X    double l, sl, cl, y;
  656. X    double spsi, cpsi;
  657. X    double rd, lsn, rsn;
  658. X    double lg, re, ll;
  659. X    double cll, sll;
  660. X    double nu;
  661. X
  662. X#define    ERRLMT    0.0001
  663. X        w = ((mjd-ep)*3.649116e-02)/(qp*sqrt(qp));
  664. X        s = w/3;
  665. X    while (1) {
  666. X        double d;
  667. X        s2 = s*s;
  668. X        d = (s2+3)*s-w;
  669. X        if (fabs(d) <= ERRLMT)
  670. X        break;
  671. X        s = ((2*s*s2)+w)/(3*(s2+1));
  672. X    }
  673. X
  674. X        nu = 2*atan(s);
  675. X    *rp = qp*(1+s2);
  676. X    l = nu+ap;
  677. X        sl = sin(l);
  678. X    cl = cos(l);
  679. X    spsi = sl*sin(inc);
  680. X        *psi = asin(spsi);
  681. X    y = sl*cos(inc);
  682. X        *lpd = atan(y/cl)+om;
  683. X    cpsi = cos(*psi);
  684. X        if (cl<0) *lpd += PI;
  685. X    range (lpd, 2*PI);
  686. X        rd = *rp * cpsi;
  687. X    sunpos (mjd, &lsn, &rsn);
  688. X    lg = lsn+PI;
  689. X        re = rsn;
  690. X    ll = *lpd - lg;
  691. X        cll = cos(ll);
  692. X    sll = sin(ll);
  693. X        *rho = sqrt((re * re)+(*rp * *rp)-(2*re*rd*cll));
  694. X        if (rd<re) 
  695. X            *lam = atan((-1*rd*sll)/(re-(rd*cll)))+lg+PI;
  696. X    else
  697. X        *lam = atan((re*sll)/(rd-(re*cll)))+*lpd;
  698. X    range (lam, 2*PI);
  699. X        *bet = atan((rd*spsi*sin(*lam-*lpd))/(cpsi*re*sll));
  700. X}
  701. END_OF_FILE
  702.   if test 2390 -ne `wc -c <'comet.c'`; then
  703.     echo shar: \"'comet.c'\" unpacked with wrong size!
  704.   fi
  705.   # end of 'comet.c'
  706. fi
  707. if test -f 'moon.c' -a "${1}" != "-c" ; then 
  708.   echo shar: Will not clobber existing file \"'moon.c'\"
  709. else
  710.   echo shar: Extracting \"'moon.c'\" \(5143 characters\)
  711.   sed "s/^X//" >'moon.c' <<'END_OF_FILE'
  712. X#include <stdio.h>
  713. X#include <math.h>
  714. X#include "astro.h"
  715. X
  716. X/* given the mjd, find the geocentric ecliptic longitude, lam, and latitude,
  717. X * bet, and horizontal parallax, hp for the moon.
  718. X * N.B. series for long and lat are good to about 10 and 3 arcseconds. however,
  719. X *   math errors cause up to 100 and 30 arcseconds error, even if use double.
  720. X *   why?? suspect highly sensitive nature of difference used to get m1..6.
  721. X * N.B. still need to correct for nutation. then for topocentric location
  722. X *   further correct for parallax and refraction.
  723. X */
  724. Xmoon (mjd, lam, bet, hp)
  725. Xdouble mjd;
  726. Xdouble *lam, *bet, *hp;
  727. X{
  728. X    double t, t2;
  729. X    double ld;
  730. X    double ms;
  731. X    double md;
  732. X    double de;
  733. X    double f;
  734. X    double n;
  735. X    double a, sa, sn, b, sb, c, sc, e, e2, l, g, w1, w2;
  736. X    double m1, m2, m3, m4, m5, m6;
  737. X
  738. X    t = mjd/36525.;
  739. X    t2 = t*t;
  740. X
  741. X    m1 = mjd/27.32158213;
  742. X    m1 = 360.0*(m1-(long)m1);
  743. X    m2 = mjd/365.2596407;
  744. X    m2 = 360.0*(m2-(long)m2);
  745. X    m3 = mjd/27.55455094;
  746. X    m3 = 360.0*(m3-(long)m3);
  747. X    m4 = mjd/29.53058868;
  748. X    m4 = 360.0*(m4-(long)m4);
  749. X    m5 = mjd/27.21222039;
  750. X    m5 = 360.0*(m5-(long)m5);
  751. X    m6 = mjd/6798.363307;
  752. X    m6 = 360.0*(m6-(long)m6);
  753. X
  754. X    ld = 270.434164+m1-(.001133-.0000019*t)*t2;
  755. X    ms = 358.475833+m2-(.00015+.0000033*t)*t2;
  756. X    md = 296.104608+m3+(.009192+.0000144*t)*t2;
  757. X    de = 350.737486+m4-(.001436-.0000019*t)*t2;
  758. X    f = 11.250889+m5-(.003211+.0000003*t)*t2;
  759. X    n = 259.183275-m6+(.002078+.000022*t)*t2;
  760. X
  761. X    a = degrad(51.2+20.2*t);
  762. X    sa = sin(a);
  763. X    sn = sin(degrad(n));
  764. X    b = 346.56+(132.87-.0091731*t)*t;
  765. X    sb = .003964*sin(degrad(b));
  766. X    c = degrad(n+275.05-2.3*t);
  767. X    sc = sin(c);
  768. X    ld = ld+.000233*sa+sb+.001964*sn;
  769. X    ms = ms-.001778*sa;
  770. X    md = md+.000817*sa+sb+.002541*sn;
  771. X    f = f+sb-.024691*sn-.004328*sc;
  772. X    de = de+.002011*sa+sb+.001964*sn;
  773. X    e = 1-(.002495+7.52e-06*t)*t;
  774. X    e2 = e*e;
  775. X
  776. X    ld = degrad(ld);
  777. X    ms = degrad(ms);
  778. X    n = degrad(n);
  779. X    de = degrad(de);
  780. X    f = degrad(f);
  781. X    md = degrad(md);
  782. X
  783. X    l = 6.28875*sin(md)+1.27402*sin(2*de-md)+.658309*sin(2*de)+
  784. X        .213616*sin(2*md)-e*.185596*sin(ms)-.114336*sin(2*f)+
  785. X        .058793*sin(2*(de-md))+.057212*e*sin(2*de-ms-md)+
  786. X        .05332*sin(2*de+md)+.045874*e*sin(2*de-ms)+.041024*e*sin(md-ms);
  787. X    l = l-.034718*sin(de)-e*.030465*sin(ms+md)+.015326*sin(2*(de-f))-
  788. X        .012528*sin(2*f+md)-.01098*sin(2*f-md)+.010674*sin(4*de-md)+
  789. X        .010034*sin(3*md)+.008548*sin(4*de-2*md)-e*.00791*sin(ms-md+2*de)-
  790. X        e*.006783*sin(2*de+ms);
  791. X    l = l+.005162*sin(md-de)+e*.005*sin(ms+de)+.003862*sin(4*de)+
  792. X        e*.004049*sin(md-ms+2*de)+.003996*sin(2*(md+de))+
  793. X        .003665*sin(2*de-3*md)+e*.002695*sin(2*md-ms)+
  794. X        .002602*sin(md-2*(f+de))+e*.002396*sin(2*(de-md)-ms)-
  795. X        .002349*sin(md+de);
  796. X    l = l+e2*.002249*sin(2*(de-ms))-e*.002125*sin(2*md+ms)-
  797. X        e2*.002079*sin(2*ms)+e2*.002059*sin(2*(de-ms)-md)-
  798. X        .001773*sin(md+2*(de-f))-.001595*sin(2*(f+de))+
  799. X        e*.00122*sin(4*de-ms-md)-.00111*sin(2*(md+f))+.000892*sin(md-3*de);
  800. X    l = l-e*.000811*sin(ms+md+2*de)+e*.000761*sin(4*de-ms-2*md)+
  801. X         e2*.000704*sin(md-2*(ms+de))+e*.000693*sin(ms-2*(md-de))+
  802. X         e*.000598*sin(2*(de-f)-ms)+.00055*sin(md+4*de)+.000538*sin(4*md)+
  803. X         e*.000521*sin(4*de-ms)+.000486*sin(2*md-de);
  804. X    l = l+e2*.000717*sin(md-2*ms);
  805. X    *lam = ld+degrad(l);
  806. X    range (lam, 2*PI);
  807. X
  808. X    g = 5.12819*sin(f)+.280606*sin(md+f)+.277693*sin(md-f)+
  809. X        .173238*sin(2*de-f)+.055413*sin(2*de+f-md)+.046272*sin(2*de-f-md)+
  810. X        .032573*sin(2*de+f)+.017198*sin(2*md+f)+.009267*sin(2*de+md-f)+
  811. X        .008823*sin(2*md-f)+e*.008247*sin(2*de-ms-f);
  812. X    g = g+.004323*sin(2*(de-md)-f)+.0042*sin(2*de+f+md)+
  813. X        e*.003372*sin(f-ms-2*de)+e*.002472*sin(2*de+f-ms-md)+
  814. X        e*.002222*sin(2*de+f-ms)+e*.002072*sin(2*de-f-ms-md)+
  815. X        e*.001877*sin(f-ms+md)+.001828*sin(4*de-f-md)-e*.001803*sin(f+ms)-
  816. X        .00175*sin(3*f);
  817. X    g = g+e*.00157*sin(md-ms-f)-.001487*sin(f+de)-e*.001481*sin(f+ms+md)+
  818. X         e*.001417*sin(f-ms-md)+e*.00135*sin(f-ms)+.00133*sin(f-de)+
  819. X         .001106*sin(f+3*md)+.00102*sin(4*de-f)+.000833*sin(f+4*de-md)+
  820. X         .000781*sin(md-3*f)+.00067*sin(f+4*de-2*md);
  821. X    g = g+.000606*sin(2*de-3*f)+.000597*sin(2*(de+md)-f)+
  822. X        e*.000492*sin(2*de+md-ms-f)+.00045*sin(2*(md-de)-f)+
  823. X        .000439*sin(3*md-f)+.000423*sin(f+2*(de+md))+
  824. X        .000422*sin(2*de-f-3*md)-e*.000367*sin(ms+f+2*de-md)-
  825. X        e*.000353*sin(ms+f+2*de)+.000331*sin(f+4*de);
  826. X    g = g+e*.000317*sin(2*de+f-ms+md)+e2*.000306*sin(2*(de-ms)-f)-
  827. X        .000283*sin(md+3*f);
  828. X    w1 = .0004664*cos(n);
  829. X    w2 = .0000754*cos(c);
  830. X    *bet = degrad(g)*(1-w1-w2);
  831. X
  832. X    *hp = .950724+.051818*cos(md)+.009531*cos(2*de-md)+.007843*cos(2*de)+
  833. X          .002824*cos(2*md)+.000857*cos(2*de+md)+e*.000533*cos(2*de-ms)+
  834. X          e*.000401*cos(2*de-md-ms)+e*.00032*cos(md-ms)-.000271*cos(de)-
  835. X          e*.000264*cos(ms+md)-.000198*cos(2*f-md);
  836. X    *hp = *hp+.000173*cos(3*md)+.000167*cos(4*de-md)-e*.000111*cos(ms)+
  837. X         .000103*cos(4*de-2*md)-.000084*cos(2*md-2*de)-
  838. X         e*.000083*cos(2*de+ms)+.000079*cos(2*de+2*md)+.000072*cos(4*de)+
  839. X         e*.000064*cos(2*de-ms+md)-e*.000063*cos(2*de+ms-md)+
  840. X         e*.000041*cos(ms+de);
  841. X    *hp = *hp+e*.000035*cos(2*md-ms)-.000033*cos(3*md-2*de)-
  842. X         .00003*cos(md+de)-.000029*cos(2*(f-de))-e*.000029*cos(2*md+ms)+
  843. X         e2*.000026*cos(2*(de-ms))-.000023*cos(2*(f-de)+md)+
  844. X         e*.000019*cos(4*de-ms-md);
  845. X    *hp = degrad(*hp);
  846. X}
  847. END_OF_FILE
  848.   if test 5143 -ne `wc -c <'moon.c'`; then
  849.     echo shar: \"'moon.c'\" unpacked with wrong size!
  850.   fi
  851.   # end of 'moon.c'
  852. fi
  853. if test -f 'pelement.c' -a "${1}" != "-c" ; then 
  854.   echo shar: Will not clobber existing file \"'pelement.c'\"
  855. else
  856.   echo shar: Extracting \"'pelement.c'\" \(4797 characters\)
  857.   sed "s/^X//" >'pelement.c' <<'END_OF_FILE'
  858. X#include <stdio.h>
  859. X#include <math.h>
  860. X#include "astro.h"
  861. X
  862. X/* this array contains polynomial coefficients to find the various orbital
  863. X *   elements for the mean orbit at any instant in time for each major planet.
  864. X *   the first five elements are in the form a0 + a1*t + a2*t**2 + a3*t**3,
  865. X *   where t is the number of Julian centuries of 36525 Julian days since 1900
  866. X *   Jan 0.5. the last three elements are constants.
  867. X *
  868. X * the orbital element (column) indeces are:
  869. X *   [ 0- 3]: coefficients for mean longitude, in degrees;
  870. X *   [ 4- 7]: coefficients for longitude of the perihelion, in degrees;
  871. X *   [ 8-11]: coefficients for eccentricity;
  872. X *   [12-15]: coefficients for inclination, in degrees;
  873. X *   [16-19]: coefficients for longitude of the ascending node, in degrees;
  874. X *      [20]: semi-major axis, in AU;
  875. X *      [21]: angular diameter at 1 AU, in arcsec;
  876. X *      [22]: standard visual magnitude, ie, the visual magnitude of the planet
  877. X *          when at a distance of 1 AU from both the Sun and the Earth and
  878. X *          with zero phase angle.
  879. X *
  880. X * the planent (row) indeces are:
  881. X *   [0]: Mercury; [1]: Venus;   [2]: Mars;  [3]: Jupiter; [4]: Saturn;
  882. X *   [5]: Uranus;  [6]: Neptune; [7]: Pluto.
  883. X */
  884. X#define    NPELE    (5*4 + 3)    /* 4 coeffs for ea of 5 elems, + 3 constants */
  885. Xstatic double elements[8][NPELE] = {
  886. X
  887. X    {   /*     mercury... */
  888. X
  889. X        178.179078,    415.2057519,    3.011e-4,    0.0,
  890. X        75.899697,    1.5554889,    2.947e-4,    0.0,
  891. X        .20561421,    2.046e-5,    3e-8,        0.0,
  892. X        7.002881,    1.8608e-3,    -1.83e-5,    0.0,
  893. X        47.145944,    1.1852083,    1.739e-4,    0.0,
  894. X        .3870986,    6.74,         -0.42
  895. X    },
  896. X
  897. X    {   /*     venus... */
  898. X
  899. X        342.767053,    162.5533664,    3.097e-4,    0.0,
  900. X        130.163833,    1.4080361,    -9.764e-4,    0.0,
  901. X        6.82069e-3,    -4.774e-5,    9.1e-8,        0.0,
  902. X        3.393631,    1.0058e-3,    -1e-6,        0.0,
  903. X        75.779647,    .89985,        4.1e-4,        0.0,
  904. X        .7233316,    16.92,        -4.4
  905. X    },
  906. X
  907. X    {   /*     mars... */
  908. X
  909. X        293.737334,    53.17137642,    3.107e-4,    0.0,
  910. X        3.34218203e2, 1.8407584,    1.299e-4,    -1.19e-6,
  911. X        9.33129e-2,    9.2064e-5,    7.7e-8,        0.0,
  912. X        1.850333,    -6.75e-4,    1.26e-5,    0.0,
  913. X        48.786442,    .7709917,    -1.4e-6,    -5.33e-6,
  914. X        1.5236883,    9.36,        -1.52
  915. X    },
  916. X
  917. X    {   /*     jupiter... */
  918. X
  919. X        238.049257,    8.434172183,    3.347e-4,    -1.65e-6,
  920. X        1.2720972e1, 1.6099617,    1.05627e-3,    -3.43e-6,
  921. X        4.833475e-2, 1.6418e-4,    -4.676e-7,    -1.7e-9,
  922. X        1.308736,    -5.6961e-3,    3.9e-6,        0.0,
  923. X        99.443414,    1.01053,    3.5222e-4,    -8.51e-6,
  924. X        5.202561,    196.74,        -9.4
  925. X    },
  926. X
  927. X    {   /*     saturn... */
  928. X
  929. X        266.564377,    3.398638567,    3.245e-4,    -5.8e-6,
  930. X        9.1098214e1, 1.9584158,    8.2636e-4,    4.61e-6,
  931. X        5.589232e-2, -3.455e-4,    -7.28e-7,    7.4e-10,
  932. X        2.492519,    -3.9189e-3,    -1.549e-5,    4e-8,
  933. X        112.790414,    .8731951,    -1.5218e-4,    -5.31e-6,
  934. X        9.554747,    165.6,        -8.88
  935. X    },
  936. X
  937. X    {   /*     uranus... */
  938. X
  939. X        244.19747,    1.194065406,    3.16e-4,    -6e-7,
  940. X        1.71548692e2, 1.4844328,    2.372e-4,    -6.1e-7,
  941. X        4.63444e-2,    -2.658e-5,    7.7e-8,        0.0,
  942. X        .772464,    6.253e-4,    3.95e-5,    0.0,
  943. X        73.477111,    .4986678,    1.3117e-3,    0.0,
  944. X        19.21814,    65.8,        -7.19
  945. X    },
  946. X
  947. X    {   /*     neptune... */
  948. X
  949. X        84.457994,    .6107942056,    3.205e-4,    -6e-7,
  950. X        4.6727364e1, 1.4245744,    3.9082e-4,    -6.05e-7,
  951. X        8.99704e-3,    6.33e-6,    -2e-9,        0.0,
  952. X        1.779242,    -9.5436e-3,    -9.1e-6,    0.0,
  953. X        130.681389,    1.098935,    2.4987e-4,    -4.718e-6,
  954. X        30.10957,    62.2,        -6.87
  955. X    },
  956. X
  957. X    {   /*     pluto...(osculating 1984 jan 21) */
  958. X
  959. X        95.3113544,    .3980332167,    0.0,        0.0,
  960. X        224.017,    0.0,        0.0,        0.0,
  961. X        .25515,    0.0,        0.0,        0.0,
  962. X        17.1329,    0.0,        0.0,        0.0,
  963. X        110.191,    0.0,        0.0,        0.0,
  964. X        39.8151,    8.2,        -1.0
  965. X    }
  966. X};
  967. X
  968. X/* given a modified Julian date, mjd, return the elements for the mean orbit
  969. X *   at that instant of all the major planets, together with their
  970. X *   mean daily motions in longitude, angular diameter and standard visual
  971. X *   magnitude.
  972. X * plan[i][j] contains all the values for all the planets at mjd, such that
  973. X *   i = 0..7: mercury, venus, mars, jupiter, saturn, unranus, neptune, pluto;
  974. X *   j = 0..8: mean longitude, mean daily motion in longitude, longitude of 
  975. X *     the perihelion, eccentricity, inclination, longitude of the ascending
  976. X *     node, length of the semi-major axis, angular diameter from 1 AU, and
  977. X *     the standard visual magnitude (see elements[][] comment, above).
  978. X */
  979. Xpelement (mjd, plan)
  980. Xdouble mjd;
  981. Xdouble plan[8][9];
  982. X{
  983. X    register double *ep, *pp;
  984. X    register double t = mjd/36525.;
  985. X    double aa;
  986. X    int planet, i;
  987. X
  988. X    for (planet = 0; planet < 8; planet++) {
  989. X        ep = elements[planet];
  990. X        pp = plan[planet];
  991. X        aa = ep[1]*t;
  992. X        pp[0] = ep[0] + 360.*(aa-(long)aa) + (ep[3]*t + ep[2])*t*t;
  993. X        range (pp, 360.);
  994. X        pp[1] = (ep[1]*9.856263e-3) + (ep[2] + ep[3])/36525;
  995. X
  996. X        for (i = 4; i < 20; i += 4)
  997. X        pp[i/4+1] = ((ep[i+3]*t + ep[i+2])*t + ep[i+1])*t + ep[i+0];
  998. X
  999. X        pp[6] = ep[20];
  1000. X        pp[7] = ep[21];
  1001. X        pp[8] = ep[22];
  1002. X    }
  1003. X}
  1004. END_OF_FILE
  1005.   if test 4797 -ne `wc -c <'pelement.c'`; then
  1006.     echo shar: \"'pelement.c'\" unpacked with wrong size!
  1007.   fi
  1008.   # end of 'pelement.c'
  1009. fi
  1010. if test -f 'precess.c' -a "${1}" != "-c" ; then 
  1011.   echo shar: Will not clobber existing file \"'precess.c'\"
  1012. else
  1013.   echo shar: Extracting \"'precess.c'\" \(2952 characters\)
  1014.   sed "s/^X//" >'precess.c' <<'END_OF_FILE'
  1015. X#include <stdio.h>
  1016. X#include <math.h>
  1017. X#include "astro.h"
  1018. X
  1019. X#define    DCOS(x)        cos(degrad(x))
  1020. X#define    DSIN(x)        sin(degrad(x))
  1021. X#define    DASIN(x)    raddeg(asin(x))
  1022. X#define    DATAN2(y,x)    raddeg(atan2((y),(x)))
  1023. X
  1024. X/* corrects ra and dec, both in radians, for precession from epoch 1 to epoch 2.
  1025. X * the epochs are given by their modified JDs, mjd1 and mjd2, respectively.
  1026. X * N.B. ra and dec are modifed IN PLACE.
  1027. X */
  1028. X
  1029. X/*
  1030. X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
  1031. X *
  1032. X * This software may be redistributed freely, not sold.
  1033. X * This copyright notice and disclaimer of warranty must remain
  1034. X *    unchanged. 
  1035. X *
  1036. X * No representation is made about the suitability of this
  1037. X * software for any purpose.  It is provided "as is" without express or
  1038. X * implied warranty, to the extent permitted by applicable law.
  1039. X *
  1040. X * Rigorous precession. From Astronomical Ephemeris 1989, p. B18
  1041. X */
  1042. X
  1043. Xprecess (mjd1, mjd2, ra, dec)
  1044. Xdouble mjd1, mjd2;    /* initial and final epoch modified JDs */
  1045. Xdouble *ra, *dec;    /* ra/dec for mjd1 in, for mjd2 out */
  1046. X{
  1047. X    double zeta_A, z_A, theta_A;
  1048. X    double T;
  1049. X    double A, B, C;
  1050. X    double alpha, delta;
  1051. X    double alpha_in, delta_in;
  1052. X    double from_equinox, to_equinox;
  1053. X    double alpha2000, delta2000;
  1054. X
  1055. X    mjd_year (mjd1, &from_equinox);
  1056. X    mjd_year (mjd2, &to_equinox);
  1057. X    alpha_in = raddeg(*ra);
  1058. X    delta_in = raddeg(*dec);
  1059. X
  1060. X    /* From from_equinox to 2000.0 */
  1061. X    if (from_equinox != 2000.0) {
  1062. X        T = (from_equinox - 2000.0)/100.0;
  1063. X        zeta_A  = 0.6406161* T + 0.0000839* T*T + 0.0000050* T*T*T;
  1064. X        z_A     = 0.6406161* T + 0.0003041* T*T + 0.0000051* T*T*T;
  1065. X        theta_A = 0.5567530* T - 0.0001185* T*T + 0.0000116* T*T*T;
  1066. X
  1067. X        A = DSIN(alpha_in - z_A) * DCOS(delta_in);
  1068. X        B = DCOS(alpha_in - z_A) * DCOS(theta_A) * DCOS(delta_in)
  1069. X          + DSIN(theta_A) * DSIN(delta_in);
  1070. X        C = -DCOS(alpha_in - z_A) * DSIN(theta_A) * DCOS(delta_in)
  1071. X          + DCOS(theta_A) * DSIN(delta_in);
  1072. X
  1073. X        alpha2000 = DATAN2(A,B) - zeta_A;
  1074. X        range (&alpha2000, 360.0);
  1075. X        delta2000 = DASIN(C);
  1076. X    } else {
  1077. X        /* should get the same answer, but this could improve accruacy */
  1078. X        alpha2000 = alpha_in;
  1079. X        delta2000 = delta_in;
  1080. X    };
  1081. X
  1082. X
  1083. X    /* From 2000.0 to to_equinox */
  1084. X    if (to_equinox != 2000.0) {
  1085. X        T = (to_equinox - 2000.0)/100.0;
  1086. X        zeta_A  = 0.6406161* T + 0.0000839* T*T + 0.0000050* T*T*T;
  1087. X        z_A     = 0.6406161* T + 0.0003041* T*T + 0.0000051* T*T*T;
  1088. X        theta_A = 0.5567530* T - 0.0001185* T*T + 0.0000116* T*T*T;
  1089. X
  1090. X        A = DSIN(alpha2000 + zeta_A) * DCOS(delta2000);
  1091. X        B = DCOS(alpha2000 + zeta_A) * DCOS(theta_A) * DCOS(delta2000)
  1092. X          - DSIN(theta_A) * DSIN(delta2000);
  1093. X        C = DCOS(alpha2000 + zeta_A) * DSIN(theta_A) * DCOS(delta2000)
  1094. X          + DCOS(theta_A) * DSIN(delta2000);
  1095. X
  1096. X        alpha = DATAN2(A,B) + z_A;
  1097. X        range(&alpha, 360.0);
  1098. X        delta = DASIN(C);
  1099. X    } else {
  1100. X        /* should get the same answer, but this could improve accruacy */
  1101. X        alpha = alpha2000;
  1102. X        delta = delta2000;
  1103. X    };
  1104. X
  1105. X    *ra = degrad(alpha);
  1106. X    *dec = degrad(delta);
  1107. X}
  1108. END_OF_FILE
  1109.   if test 2952 -ne `wc -c <'precess.c'`; then
  1110.     echo shar: \"'precess.c'\" unpacked with wrong size!
  1111.   fi
  1112.   # end of 'precess.c'
  1113. fi
  1114. if test -f 'refract.c' -a "${1}" != "-c" ; then 
  1115.   echo shar: Will not clobber existing file \"'refract.c'\"
  1116. else
  1117.   echo shar: Extracting \"'refract.c'\" \(1857 characters\)
  1118.   sed "s/^X//" >'refract.c' <<'END_OF_FILE'
  1119. X#include <stdio.h>
  1120. X#include <math.h>
  1121. X#include "astro.h"
  1122. X
  1123. X/* correct the true altitude, ta, for refraction to the apparent altitude, aa,
  1124. X * each in radians, given the local atmospheric pressure, pr, in mbars, and
  1125. X * the temperature, tr, in degrees C.
  1126. X */
  1127. Xrefract (pr, tr, ta, aa)
  1128. Xdouble pr, tr;
  1129. Xdouble ta;
  1130. Xdouble *aa;
  1131. X{
  1132. X    double r;    /* refraction correction*/
  1133. X
  1134. X        if (ta >= degrad(15.)) {
  1135. X        /* model for altitudes at least 15 degrees above horizon */
  1136. X            r = 7.888888e-5*pr/((273+tr)*tan(ta));
  1137. X    } else if (ta > degrad(-5.)) {
  1138. X        /* hairier model for altitudes at least -5 and below 15 degrees */
  1139. X        double a, b, tadeg = raddeg(ta);
  1140. X        a = ((2e-5*tadeg+1.96e-2)*tadeg+1.594e-1)*pr;
  1141. X        b = (273+tr)*((8.45e-2*tadeg+5.05e-1)*tadeg+1);
  1142. X        r = degrad(a/b);
  1143. X    } else {
  1144. X        /* do nothing if more than 5 degrees below horizon.
  1145. X         */
  1146. X        r = 0;
  1147. X    }
  1148. X
  1149. X    *aa  =  ta + r;
  1150. X}
  1151. X
  1152. X/* correct the apparent altitude, aa, for refraction to the true altitude, ta,
  1153. X * each in radians, given the local atmospheric pressure, pr, in mbars, and
  1154. X * the temperature, tr, in degrees C.
  1155. X */
  1156. Xunrefract (pr, tr, aa, ta)
  1157. Xdouble pr, tr;
  1158. Xdouble aa;
  1159. Xdouble *ta;
  1160. X{
  1161. X    double err;
  1162. X    double appar;
  1163. X    double true;
  1164. X
  1165. X    /* iterative solution: search for the true that refracts to the
  1166. X     *   given apparent.
  1167. X     * since refract() is discontinuous at -5 degrees, there is a range
  1168. X     *   of apparent altitudes between about -4.5 and -5 degrees that are
  1169. X     *   not invertable (the graph of ap vs. true has a vertical step at
  1170. X     *   true = -5). thus, the iteration just oscillates if it gets into
  1171. X     *   this region. if this happens the iteration is forced to abort.
  1172. X     *   of course, this makes unrefract() discontinuous too.
  1173. X     */
  1174. X    true = aa;
  1175. X    do {
  1176. X        refract (pr, tr, true, &appar);
  1177. X        err = appar - aa;
  1178. X        true -= err;
  1179. X    } while (fabs(err) >= 1e-6 && true > degrad(-5));
  1180. X
  1181. X    *ta = true;
  1182. X}
  1183. END_OF_FILE
  1184.   if test 1857 -ne `wc -c <'refract.c'`; then
  1185.     echo shar: \"'refract.c'\" unpacked with wrong size!
  1186.   fi
  1187.   # end of 'refract.c'
  1188. fi
  1189. if test -f 'riset.c' -a "${1}" != "-c" ; then 
  1190.   echo shar: Will not clobber existing file \"'riset.c'\"
  1191. else
  1192.   echo shar: Extracting \"'riset.c'\" \(4591 characters\)
  1193.   sed "s/^X//" >'riset.c' <<'END_OF_FILE'
  1194. X#include <stdio.h>
  1195. X#include <math.h>
  1196. X#include "astro.h"
  1197. X
  1198. X/* given the true geocentric ra and dec of an object, the observer's latitude,
  1199. X *   lat, and a horizon displacement correction, dis, all in radians, find the
  1200. X *   local sidereal times and azimuths of rising and setting, lstr/s
  1201. X *   and azr/s, also all in radians, respectively.
  1202. X * dis is the vertical displacement from the true position of the horizon. it
  1203. X *   is positive if the apparent position is higher than the true position.
  1204. X *   said another way, it is positive if the shift causes the object to spend
  1205. X *   longer above the horizon. for example, atmospheric refraction is typically
  1206. X *   assumed to produce a vertical shift of 34 arc minutes at the horizon; dis
  1207. X *   would then take on the value +9.89e-3 (radians). On the other hand, if
  1208. X *   your horizon has hills such that your apparent horizon is, say, 1 degree
  1209. X *   above sea level, you would allow for this by setting dis to -1.75e-2
  1210. X *   (radians).
  1211. X *
  1212. X * algorithm:
  1213. X *   the situation is described by two spherical triangles with two equal angles
  1214. X *    (the right horizon intercepts, and the common horizon transverse):
  1215. X *   given lat, d(=d1+d2), and dis find z(=z1+z2) and rho, where      /| eq pole
  1216. X *     lat = latitude,                                              /  |
  1217. X *     dis = horizon displacement (>0 is below ideal)             / rho|
  1218. X *     d = angle from pole = PI/2 - declination                /       |
  1219. X *     z = azimuth east of north                            /          |
  1220. X *     rho = polar rotation from down = PI - hour angle    /           | 
  1221. X *   solve simultaneous equations for d1 and d2:         /             |
  1222. X *     1) cos(d) = cos(d1+d2)                           / d2           | lat
  1223. X *            = cos(d1)cos(d2) - sin(d1)sin(d2)        /               |
  1224. X *     2) sin(d2) = sin(lat)sin(d1)/sin(dis)          /                |
  1225. X *   then can solve for z1, z2 and rho, taking       /                 |
  1226. X *     care to preserve quadrant information.       /                 -|
  1227. X *                                              z1 /        z2       | |
  1228. X *                      ideal horizon ------------/--------------------| 
  1229. X *                                         | |   /                     N
  1230. X *                                          -|  / d1
  1231. X *                                       dis | /
  1232. X *                                           |/
  1233. X *                  apparent horizon  ---------------------------------
  1234. X *
  1235. X * note that when lat=0 this all breaks down (because d2 and z2 degenerate to 0)
  1236. X *   but fortunately then we can solve for z and rho directly.
  1237. X *
  1238. X * status: 0: normal; 1: never rises; -1: circumpolar; 2: trouble.
  1239. X */
  1240. Xriset (ra, dec, lat, dis, lstr, lsts, azr, azs, status)
  1241. Xdouble ra, dec;
  1242. Xdouble lat, dis;
  1243. Xdouble *lstr, *lsts;
  1244. Xdouble *azr, *azs;
  1245. Xint *status;
  1246. X{
  1247. X#define    EPS    (1e-6)    /* math rounding fudge - always the way, eh? */
  1248. X    double d;    /* angle from pole */
  1249. X    double h;    /* hour angle */
  1250. X    double crho;    /* cos hour-angle complement */
  1251. X    int shemi;    /* flag for southern hemisphere reflection */
  1252. X
  1253. X    d = PI/2 - dec;
  1254. X
  1255. X    /* reflect if in southern hemisphere.
  1256. X     * (then reflect azimuth back after computation.)
  1257. X     */
  1258. X    if (shemi = lat < 0) {
  1259. X        lat = -lat;
  1260. X        d = PI - d;
  1261. X    }
  1262. X
  1263. X    /* do the easy ones (and avoid violated assumptions) if d arc never
  1264. X     * meets horizon. 
  1265. X     */
  1266. X    if (d <= lat + dis + EPS) {
  1267. X        *status = -1; /* never sets */
  1268. X        return;
  1269. X    }
  1270. X    if (d >= PI - lat + dis - EPS) {
  1271. X        *status = 1; /* never rises */
  1272. X        return;
  1273. X    }
  1274. X
  1275. X    /* find rising azimuth and cosine of hour-angle complement */
  1276. X    if (lat > EPS) {
  1277. X        double d2, d1; /* polr arc to ideal hzn, and corrctn for apparent */
  1278. X        double z2, z1; /* azimuth to ideal horizon, and " */
  1279. X        double a;       /* intermediate temp */
  1280. X        double sdis, slat, clat, cz2, cd2;    /* trig temps */
  1281. X        sdis = sin(dis);
  1282. X        slat = sin(lat);
  1283. X        a = sdis*sdis + slat*slat + 2*cos(d)*sdis*slat;
  1284. X        if (a <= 0) {
  1285. X        *status = 2; /* can't happen - hah! */
  1286. X        return;
  1287. X        }
  1288. X        d1 = asin (sin(d) * sdis / sqrt(a));
  1289. X        d2 = d - d1;
  1290. X        cd2 = cos(d2);
  1291. X        clat = cos(lat);
  1292. X        cz2 = cd2/clat;
  1293. X        z2 = acos (cz2);
  1294. X        z1 = acos (cos(d1)/cos(dis));
  1295. X        if (dis < 0)
  1296. X        z1 = -z1;
  1297. X        *azr = z1 + z2;
  1298. X        range (azr, PI);
  1299. X        crho = (cz2 - cd2*clat)/(sin(d2)*slat);
  1300. X    } else {
  1301. X        *azr = acos (cos(d)/cos(dis));
  1302. X        crho = sin(dis)/sin(d);
  1303. X    }
  1304. X
  1305. X    if (shemi)
  1306. X        *azr = PI - *azr;
  1307. X        *azs = 2*PI - *azr;
  1308. X    
  1309. X    /* find hour angle */
  1310. X    h = PI - acos (crho);
  1311. X        *lstr = radhr(ra-h);
  1312. X    *lsts = radhr(ra+h);
  1313. X    range (lstr, 24.0);
  1314. X    range (lsts, 24.0);
  1315. X
  1316. X    *status = 0;
  1317. X}
  1318. END_OF_FILE
  1319.   if test 4591 -ne `wc -c <'riset.c'`; then
  1320.     echo shar: \"'riset.c'\" unpacked with wrong size!
  1321.   fi
  1322.   # end of 'riset.c'
  1323. fi
  1324. if test -f 'screen.h' -a "${1}" != "-c" ; then 
  1325.   echo shar: Will not clobber existing file \"'screen.h'\"
  1326. else
  1327.   echo shar: Extracting \"'screen.h'\" \(5816 characters\)
  1328.   sed "s/^X//" >'screen.h' <<'END_OF_FILE'
  1329. X/* screen layout details
  1330. X *
  1331. X * it looks better if the fields are drawn in some nice order so it you
  1332. X * rearrange the fields, check the menu printing functions.
  1333. X * NB: all row/col values are 1 based, with upper left at [1,1]
  1334. X */
  1335. X
  1336. X/* size of screen */
  1337. X#define    NR    24
  1338. X#define    NC    80
  1339. X
  1340. X#define    ASPECT    (4./3.)    /* screen width to height dimensions ratio */
  1341. X
  1342. X#define    GAP    6    /* gap between field name and value */
  1343. X
  1344. X#define    COL1        1
  1345. X#define    COL2        27
  1346. X#define    COL3        44
  1347. X#define    COL4        61    /* calendar */
  1348. X
  1349. X#define    R_PROMPT    1    /* prompt row */
  1350. X#define    C_PROMPT    COL1
  1351. X
  1352. X#define    R_NEWCIR    2
  1353. X#define    C_NEWCIR    ((NC-17)/2) /* 17 is length of the message */
  1354. X
  1355. X#define    R_TOP        3    /* first row of top menu items */
  1356. X
  1357. X#define    R_TZN    (R_TOP+0)
  1358. X#define    C_TZN    COL1
  1359. X#define    R_LT    R_TZN
  1360. X#define    C_LT    (C_TZN+GAP-2)
  1361. X#define    R_LD    R_TZN
  1362. X#define    C_LD    (C_TZN+13)
  1363. X
  1364. X#define    R_UT    (R_TOP+1)
  1365. X#define    C_UT    COL1
  1366. X#define    C_UTV    (C_UT+GAP-2)
  1367. X#define    R_UD    R_UT
  1368. X#define    C_UD    (C_UT+13)
  1369. X
  1370. X#define    R_JD    (R_TOP+2)
  1371. X#define    C_JD    COL1
  1372. X#define    C_JDV    (C_JD+GAP+3)
  1373. X
  1374. X#define    R_LST    (R_TOP)
  1375. X#define    C_LST    COL2
  1376. X#define    C_LSTV    (C_LST+GAP)
  1377. X
  1378. X#define    R_LAT    (R_TOP+0)
  1379. X#define    C_LAT    COL3
  1380. X#define    C_LATV    (C_LAT+4)
  1381. X
  1382. X#define    R_DAWN    (R_TOP+2)
  1383. X#define    C_DAWN    COL2
  1384. X#define    C_DAWNV    (C_DAWN+GAP+3)
  1385. X
  1386. X#define    R_STPSZ    (R_TOP+7)
  1387. X#define    C_STPSZ    COL2
  1388. X#define    C_STPSZV (C_STPSZ+GAP-1)
  1389. X
  1390. X#define    R_HEIGHT (R_TOP+2)
  1391. X#define    C_HEIGHT COL3
  1392. X#define    C_HEIGHTV (C_HEIGHT+GAP)
  1393. X
  1394. X#define    R_PRES    (R_TOP+4)
  1395. X#define    C_PRES    COL3
  1396. X#define    C_PRESV    (C_PRES+GAP)
  1397. X
  1398. X#define    R_WATCH    (R_TOP+3)
  1399. X#define    C_WATCH    COL1
  1400. X
  1401. X#define    R_LISTING (R_TOP+4)
  1402. X#define    C_LISTING COL1
  1403. X#define    C_LISTINGV (C_LISTING+20)
  1404. X
  1405. X#define    R_SRCH    (R_TOP+5)
  1406. X#define    C_SRCH    COL1
  1407. X#define    C_SRCHV    (C_SRCH+16)
  1408. X
  1409. X#define    R_PLOT    (R_TOP+6)
  1410. X#define    C_PLOT    COL1
  1411. X#define    C_PLOTV (C_PLOT+20)
  1412. X
  1413. X#define    R_ALTM    (R_TOP+7)
  1414. X#define    C_ALTM    COL1
  1415. X#define    C_ALTMV    (C_ALTM+10)
  1416. X
  1417. X#define    R_TZONE    (R_TOP+5)
  1418. X#define    C_TZONE    COL3
  1419. X#define    C_TZONEV (C_TZONE+GAP-1)
  1420. X
  1421. X#define    R_LONG    (R_TOP+1)
  1422. X#define    C_LONG    COL3
  1423. X#define    C_LONGV    (C_LONG+4)
  1424. X
  1425. X#define    R_DUSK    (R_TOP+3)
  1426. X#define    C_DUSK    COL2
  1427. X#define    C_DUSKV    (C_DUSK+GAP+3)
  1428. X
  1429. X#define    R_NSTEP (R_TOP+6)
  1430. X#define    C_NSTEP    COL2
  1431. X#define    C_NSTEPV (C_NSTEP+GAP)
  1432. X
  1433. X#define    R_TEMP    (R_TOP+3)
  1434. X#define    C_TEMP    COL3
  1435. X#define    C_TEMPV    (C_TEMP+GAP)
  1436. X
  1437. X#define    R_EPOCH        (R_TOP+6)
  1438. X#define    C_EPOCH        COL3
  1439. X#define    C_EPOCHV    (C_EPOCH+GAP)
  1440. X
  1441. X#define    R_PAUSE (R_TOP+7)
  1442. X#define    C_PAUSE    COL3
  1443. X#define    C_PAUSEV (C_PAUSE+GAP)
  1444. X
  1445. X#define    R_MNUDEP    (R_TOP+6)
  1446. X#define    C_MNUDEP    COL3
  1447. X#define    C_MNUDEPV    (C_EPOCH+GAP)
  1448. X
  1449. X#define    R_LON    (R_TOP+4)
  1450. X#define    C_LON    COL2
  1451. X#define    C_LONV    (C_LON+GAP+3)
  1452. X
  1453. X#define    R_CAL    R_TOP
  1454. X#define    C_CAL   COL4
  1455. X
  1456. X/* planet rows */
  1457. X#define    R_PLANTAB    (R_TOP+9)
  1458. X#define    R_SUN        (R_PLANTAB+1)
  1459. X#define    R_MOON        (R_PLANTAB+2)
  1460. X#define    R_MERCURY    (R_PLANTAB+3)
  1461. X#define    R_VENUS        (R_PLANTAB+4)
  1462. X#define    R_MARS        (R_PLANTAB+5)
  1463. X#define    R_JUPITER    (R_PLANTAB+6)
  1464. X#define    R_SATURN    (R_PLANTAB+7)
  1465. X#define    R_URANUS    (R_PLANTAB+8)
  1466. X#define    R_NEPTUNE    (R_PLANTAB+9)
  1467. X#define    R_PLUTO        (R_PLANTAB+10)
  1468. X#define    R_OBJX        (R_PLANTAB+11)
  1469. X#define    R_OBJY        (R_PLANTAB+12)
  1470. X
  1471. X#define    C_OBJ        1
  1472. X#define    C_CONSTEL    2
  1473. X#define    C_XTRA        3
  1474. X
  1475. X/* menu 1 info table */
  1476. X#define    C_RA        4
  1477. X#define    C_DEC        12
  1478. X#define    C_AZ        19
  1479. X#define    C_ALT        26
  1480. X#define    C_HLONG        33
  1481. X#define    C_HLAT        40
  1482. X#define    C_EDIST        47
  1483. X#define C_SDIST     54
  1484. X#define    C_ELONG        61
  1485. X#define    C_SIZE        68
  1486. X#define    C_MAG        73
  1487. X#define    C_PHASE        78
  1488. X
  1489. X/* menu 2 screen items */
  1490. X#define    C_RISETM    7
  1491. X#define    C_RISEAZ    18
  1492. X#define    C_TRANSTM    29
  1493. X#define    C_TRANSALT    40
  1494. X#define    C_SETTM        51
  1495. X#define    C_SETAZ        62
  1496. X#define    C_TUP        73
  1497. X
  1498. X/* menu 3 items */
  1499. X#define    C_SUN        4
  1500. X#define    C_MOON        10
  1501. X#define    C_MERCURY    17
  1502. X#define    C_VENUS        23
  1503. X#define    C_MARS        30
  1504. X#define    C_JUPITER    36
  1505. X#define    C_SATURN    43
  1506. X#define    C_URANUS    49
  1507. X#define    C_NEPTUNE    56
  1508. X#define    C_PLUTO        62
  1509. X#define    C_OBJX        69
  1510. X#define    C_OBJY        75
  1511. X
  1512. X/* menu for jupiter aux info items */
  1513. X#define    R_JCML        (R_TOP+10)
  1514. X#define    C_JCMLSI    43
  1515. X#define    C_JCMLSII    60
  1516. X#define    C_JMNAMES    9
  1517. X#define    C_JMX        28
  1518. X#define    C_JMY        43
  1519. X#define    C_JMZ        58
  1520. X#define    R_JMAP        23
  1521. X#define    C_JMAP        1
  1522. X#define    R_JCOLHDNGS    17
  1523. X#define    R_IO        (R_JCOLHDNGS+1)
  1524. X#define    R_EUROPA    (R_JCOLHDNGS+2)
  1525. X#define    R_GANYMEDE    (R_JCOLHDNGS+3)
  1526. X#define    R_CALLISTO    (R_JCOLHDNGS+4)
  1527. X
  1528. X#define    PW    (NC-C_PROMPT+1)    /* total prompt line width */
  1529. X
  1530. X/* macros to pack a row/col and menu selection flags all into 16-bits.
  1531. X * (use this rather than a structure because we can compare them so easily.
  1532. X * could use bit fields and a union, but then can't init them or use switch.)
  1533. X * bit field defs: [15..13]=menu [12..11]=flags [10..0]=NC*row+column(0 based).
  1534. X * see sel_fld.c.
  1535. X * F_MNUX also used in main to manage which bottom menu is up.
  1536. X */
  1537. X#define    F_MMNU        (0<<13)    /* field is on main menu (or on all menus) */
  1538. X#define    F_MNU1        (1<<13)    /* field is on menu 1 */
  1539. X#define    F_MNU2         (2<<13)    /* field is on menu 2 */
  1540. X#define    F_MNU3        (3<<13)    /* field is on menu 3 */
  1541. X#define    F_MNUJ        (4<<13)    /* field is on jupiter menu */
  1542. X#define    F_PLT        (1<<12)    /* field may be picked for plotting or listng */
  1543. X#define    F_CHG        (1<<11)    /* field may be picked for changing */
  1544. X#define    rcfpack(r,c,f)    ((f) | (((r)-1)*NC + ((c)-1)))
  1545. X#define    unpackr(p)    (((p) & 0x7ff)/NC+1)
  1546. X#define    unpackc(p)    (((p) & 0x7ff)%NC+1)
  1547. X#define    unpackrc(p)    ((p) & 0x7ff)
  1548. X#define    tstpackf(p,f)    (((p) & ((f)&0x1800)) && \
  1549. X            (((p)&0xe000) == ((f)&0xe000) || ((p)&0xe000) == F_MMNU))
  1550. X
  1551. X/* additions to the planet defines from astro.h.
  1552. X * must not conflict, and must fit in range 0..15.
  1553. X */
  1554. X#define    SUN    (PLUTO+1)
  1555. X#define    MOON    (PLUTO+2)
  1556. X#define    OBJX    (PLUTO+3)    /* the user-defined object */
  1557. X#define    OBJY    (PLUTO+4)    /* the user-defined object */
  1558. X#define    NOBJ    (OBJY+1)    /* total number of objects */
  1559. X
  1560. X#define    cntrl(x)    ((x) & 037)
  1561. X#define    QUIT        cntrl('d')    /* char to exit program */
  1562. X#define    HELP        '?'        /* char to give help message */
  1563. X#define    REDRAW        cntrl('l')    /* char to redraw (like vi) */
  1564. X#define    VERSION        cntrl('v')    /* char to display version number */
  1565. X#define    END        'q'        /* char to quit current mode */
  1566. END_OF_FILE
  1567.   if test 5816 -ne `wc -c <'screen.h'`; then
  1568.     echo shar: \"'screen.h'\" unpacked with wrong size!
  1569.   fi
  1570.   # end of 'screen.h'
  1571. fi
  1572. if test -f 'time.c' -a "${1}" != "-c" ; then 
  1573.   echo shar: Will not clobber existing file \"'time.c'\"
  1574. else
  1575.   echo shar: Extracting \"'time.c'\" \(2888 characters\)
  1576.   sed "s/^X//" >'time.c' <<'END_OF_FILE'
  1577. X/* get the time from the os.
  1578. X *
  1579. X * here are two methods I was able to verify; pick one for your system and
  1580. X *   define exactly one of TZA or TZB:
  1581. X * TZA works on our ibm-pc/turbo-c and at&t systems,
  1582. X * TZB works on our 4.2 BSD vax.
  1583. X *
  1584. X * I'm told that on Sun OS 4.0.3 (BSD 4.3?) and Apollo SR 10.1 TZB works if
  1585. X *   you use <sys/time.h> in place of <time.h>.
  1586. X * 
  1587. X * On VMS, you DON'T want to define EITHER TZA nor TZB since it can't handle
  1588. X *   time zones, period. time_fromsys() will detect that fact based on gmtime()
  1589. X *   returning 0.
  1590. X */
  1591. X
  1592. X#define    TZB
  1593. X
  1594. X#ifdef VMS
  1595. X#undef TZA
  1596. X#undef TZB
  1597. X#endif
  1598. X
  1599. X#include <stdio.h>
  1600. X#include <time.h>
  1601. X
  1602. X#include "astro.h"
  1603. X#include "circum.h"
  1604. X
  1605. Xextern char *strncpy();
  1606. X#ifndef VMS
  1607. Xextern long time();
  1608. X#endif
  1609. X
  1610. Xstatic long c0;
  1611. Xstatic double mjd0;
  1612. X
  1613. X/* save current mjd and corresponding system clock for use by inc_mjd().
  1614. X * this establishes the base correspondence between the mjd and system clock.
  1615. X */
  1616. Xset_t0 (np)
  1617. XNow *np;
  1618. X{
  1619. X    mjd0 = mjd;
  1620. X    (void) time (&c0);
  1621. X}
  1622. X
  1623. X/* fill in n_mjd/tz/tznm from system clock.
  1624. X */
  1625. Xtime_fromsys (np)
  1626. XNow *np;
  1627. X{
  1628. X    extern struct tm *gmtime(), *localtime();
  1629. X    struct tm *tp;
  1630. X    long c;
  1631. X    double day, hr;
  1632. X
  1633. X    (void) time (&c);
  1634. X
  1635. X    tp = gmtime (&c);
  1636. X    if (tp) {
  1637. X        cal_mjd (tp->tm_mon+1, (double)tp->tm_mday, tp->tm_year+1900, &day);
  1638. X        sex_dec (tp->tm_hour, tp->tm_min, tp->tm_sec, &hr);
  1639. X        mjd = day + hr/24.0;
  1640. X        tp = localtime (&c);
  1641. X        settzstuff (tp->tm_isdst ? 1 : 0, np);
  1642. X    } else {
  1643. X        /* if gmtime() doesn't work, we assume the timezone stuff won't
  1644. X         * either, so we just use what it is and leave it alone. Some
  1645. X         * systems (like VMS) do not know about time zones, so this is the
  1646. X         * best guess in that case.
  1647. X         */
  1648. X        tp = localtime (&c);
  1649. X        cal_mjd (tp->tm_mon+1, (double)tp->tm_mday, tp->tm_year+1900, &day);
  1650. X        sex_dec (tp->tm_hour, tp->tm_min, tp->tm_sec, &hr);
  1651. X        mjd = day + hr/24.0 + tz/24.0;
  1652. X    }
  1653. X}
  1654. X
  1655. X/* given whether dst is now in effect (must be strictly 0 or 1), fill in
  1656. X * tzname and tz within np.
  1657. X */
  1658. Xstatic
  1659. Xsettzstuff (dst, np)
  1660. Xint dst;
  1661. XNow *np;
  1662. X{
  1663. X#ifdef TZA
  1664. X    extern long timezone;
  1665. X    extern char *tzname[2];
  1666. X
  1667. X    tzset();
  1668. X    tz = timezone/3600;
  1669. X    if (dst)
  1670. X        tz -= 1.0;
  1671. X    (void) strncpy (tznm, tzname[dst], sizeof(tznm)-1);
  1672. X#endif
  1673. X#ifdef TZB
  1674. X    extern char *timezone();
  1675. X    struct timeval timev;
  1676. X    struct timezone timez;
  1677. X
  1678. X    gettimeofday (&timev, &timez);
  1679. X    tz = timez.tz_minuteswest/60;
  1680. X    if (dst)
  1681. X        tz -= 1.0;
  1682. X    (void) strncpy (tznm, timezone(timez.tz_minuteswest, dst),
  1683. X                                sizeof(tznm)-1);
  1684. X#endif
  1685. X    tznm[sizeof(tznm)-1] = '\0';    /* insure string is terminated */
  1686. X}
  1687. X
  1688. Xinc_mjd (np, inc)
  1689. XNow *np;
  1690. Xdouble inc;
  1691. X{
  1692. X    if (inc == RTC) {
  1693. X        long c;
  1694. X        (void) time (&c);
  1695. X        mjd = mjd0 + (c - c0)/SPD;
  1696. X    } else
  1697. X        mjd += inc/24.0;
  1698. X
  1699. X    /* round to nearest whole second.
  1700. X     * without this, you can get fractional days so close to .5 but
  1701. X     * not quite there that mjd_hr() can return 24.0
  1702. X     */
  1703. X    rnd_second (&mjd);
  1704. X}
  1705. END_OF_FILE
  1706.   if test 2888 -ne `wc -c <'time.c'`; then
  1707.     echo shar: \"'time.c'\" unpacked with wrong size!
  1708.   fi
  1709.   # end of 'time.c'
  1710. fi
  1711. echo shar: End of archive 8 \(of 9\).
  1712. cp /dev/null ark8isdone
  1713. MISSING=""
  1714. for I in 1 2 3 4 5 6 7 8 9 ; do
  1715.     if test ! -f ark${I}isdone ; then
  1716.     MISSING="${MISSING} ${I}"
  1717.     fi
  1718. done
  1719. if test "${MISSING}" = "" ; then
  1720.     echo You have unpacked all 9 archives.
  1721.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1722. else
  1723.     echo You still must unpack the following archives:
  1724.     echo "        " ${MISSING}
  1725. fi
  1726. exit 0
  1727. exit 0 # Just in case...
  1728.