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

  1. Newsgroups: comp.sources.misc
  2. From: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
  3. Subject:  v28i088:  ephem - an interactive astronomical ephemeris, v4.28, Part05/09
  4. Message-ID: <1992Mar10.215823.16119@sparky.imd.sterling.com>
  5. X-Md4-Signature: 4ed4c4e87680e897b120410d7e931830
  6. Date: Tue, 10 Mar 1992 21:58:23 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 88
  11. Archive-name: ephem/part05
  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:  ephem.cfg main.c mainmenu.c plans.c
  21. # Wrapped by kent@sparky on Tue Mar 10 14:34:07 1992
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 5 (of 9)."'
  25. if test -f 'ephem.cfg' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'ephem.cfg'\"
  27. else
  28.   echo shar: Extracting \"'ephem.cfg'\" \(168 characters\)
  29.   sed "s/^X//" >'ephem.cfg' <<'END_OF_FILE'
  30. XUT=0:0:0
  31. XUD=5/1/1990
  32. XTZNAME=CDT
  33. XTZONE=5
  34. XLONG=93:42:8
  35. XLAT=44:50:37
  36. XHEIGHT=800
  37. XTEMP=40
  38. XPRES=29.5
  39. XSTPSZ=RTC
  40. XPROPTS=TSMevmjsunpxy
  41. XEPOCH=2000
  42. XNSTEP=1
  43. X
  44. XOBJX=Austin
  45. XOBJY=Juno
  46. END_OF_FILE
  47.   if test 168 -ne `wc -c <'ephem.cfg'`; then
  48.     echo shar: \"'ephem.cfg'\" unpacked with wrong size!
  49.   fi
  50.   # end of 'ephem.cfg'
  51. fi
  52. if test -f 'main.c' -a "${1}" != "-c" ; then 
  53.   echo shar: Will not clobber existing file \"'main.c'\"
  54. else
  55.   echo shar: Extracting \"'main.c'\" \(26117 characters\)
  56.   sed "s/^X//" >'main.c' <<'END_OF_FILE'
  57. X/* main "ephem" program. 
  58. X * -------------------------------------------------------------------
  59. X * Copyright (c) 1990,1991,1992 by Elwood Charles Downey
  60. X * 
  61. X * Permission is granted to make and distribute copies of this program
  62. X * free of charge, provided the copyright notice and this permission
  63. X * notice are preserved on all copies.  All other rights reserved.
  64. X * -------------------------------------------------------------------
  65. X * set options.
  66. X * init screen and circumstances.
  67. X * enter infinite loop updating screen and allowing operator input.
  68. X */
  69. X
  70. X#include <stdio.h>
  71. X#include <ctype.h>
  72. X#include <signal.h>
  73. X#include <setjmp.h>
  74. X#include <math.h>
  75. X#ifdef VMS
  76. X#include <stdlib.h>
  77. X#endif
  78. X#include "astro.h"
  79. X#include "circum.h"
  80. X#include "screen.h"
  81. X
  82. Xextern char *strncpy();
  83. Xextern char *getenv();
  84. X
  85. X/* shorthands for fields of a Now structure, now.
  86. X * first undo the ones for a Now pointer from circum.h.
  87. X */
  88. X#undef mjd
  89. X#undef lat
  90. X#undef lng
  91. X#undef tz
  92. X#undef temp
  93. X#undef pressure
  94. X#undef height
  95. X#undef epoch
  96. X#undef tznm
  97. X
  98. X#define mjd    now.n_mjd
  99. X#define lat    now.n_lat
  100. X#define lng    now.n_lng
  101. X#define tz    now.n_tz
  102. X#define temp    now.n_temp
  103. X#define pressure now.n_pressure
  104. X#define height    now.n_height
  105. X#define epoch    now.n_epoch
  106. X#define tznm    now.n_tznm
  107. X
  108. Xstatic jmp_buf fpe_err_jmp;    /* used to recover from SIGFPE */
  109. Xstatic char *cfgfile;        /* !0 if -c used */
  110. Xstatic char cfgdef[] = "ephem.cfg"; /* default configuration file name */
  111. Xstatic Now now;        /* where when and how, right now */
  112. Xstatic double tminc;    /* hrs to inc time by each loop; RTC means use clock */
  113. Xstatic int nstep;    /* steps to go before stopping */
  114. Xstatic int spause;    /* secs to pause between steps */
  115. Xstatic int optwi;    /* set when want to display dawn/dusk/len-of-night */
  116. Xstatic int oppl;    /* mask of (1<<planet) bits; set when want to show it */
  117. X
  118. Xmain (ac, av)
  119. Xint ac;
  120. Xchar *av[];
  121. X{
  122. X    void bye();
  123. X    void on_fpe();
  124. X    static char freerun[] =
  125. X        "Running... press any key to stop to make changes.";
  126. X    static char prmpt[] =
  127. X"Move to another field, RETURN to change this field, ? for help, or q to run";
  128. X    static char hlp[] =
  129. X    "arrow keys move to field; any key stops running; ^d exits; ^l redraws";
  130. X    int fld = rcfpack(R_NSTEP, C_NSTEPV, 0); /* initial cursor loc */
  131. X    int sflag = 0;    /* not silent, by default */
  132. X    int one = 1;    /* use a variable so optimizer doesn't get disabled */
  133. X    int srchdone = 0; /* true when search funcs say so */
  134. X    int newcir = 2;    /* set when circumstances change - means don't tminc */
  135. X
  136. X    while ((--ac > 0) && (**++av == '-')) {
  137. X        char *s;
  138. X        for (s = *av+1; *s != '\0'; s++)
  139. X        switch (*s) {
  140. X        case 's': /* no credits "silent" (don't publish this) */
  141. X            sflag++;
  142. X            break;
  143. X        case 'c': /* set name of config file to use */
  144. X            if (--ac <= 0) usage("-c but no config file");
  145. X            cfgfile = *++av;
  146. X            break;
  147. X        case 'd': /* set alternate database file name */
  148. X            if (--ac <= 0) usage("-d but no database file");
  149. X            obj_setdbfilename (*++av);
  150. X            break;
  151. X        default:
  152. X            usage("Bad - option");
  153. X        }
  154. X    }
  155. X
  156. X    if (!sflag)
  157. X        credits();
  158. X
  159. X    /* fresh screen.
  160. X     * crack config file, THEN args so args may override.
  161. X     */
  162. X    c_erase();
  163. X    read_cfgfile ();
  164. X    read_fieldargs (ac, av);
  165. X
  166. X    /* set up to clean up screen and tty if interrupted.
  167. X     * also set up to stop if get floating error.
  168. X     */
  169. X    (void) signal (SIGINT, bye);
  170. X    (void) signal (SIGFPE, on_fpe);
  171. X
  172. X    /* update screen forever (until QUIT) */
  173. X    while (one) {
  174. X
  175. X        /* if get a floating error, longjmp() here and stop looping */
  176. X        if (setjmp (fpe_err_jmp))
  177. X        nstep = 0;
  178. X        else {
  179. X        nstep -= 1;
  180. X
  181. X        /* recalculate everything and update all the fields */
  182. X        redraw_screen (newcir);
  183. X        mm_newcir (0);
  184. X
  185. X        /* let searching functions change tminc and check for done */
  186. X        srchdone = srch_eval (mjd, &tminc) < 0;
  187. X        print_tminc(0);    /* to show possibly new search increment */
  188. X
  189. X        /* update plot and listing files, now that all fields are up
  190. X         * to date and search function has been evaluated.
  191. X         */
  192. X        plot();
  193. X        listing();
  194. X
  195. X        /* handle spause if we are really looping */
  196. X        if (nstep > 0)
  197. X            slp_sync();
  198. X        }
  199. X
  200. X        /* stop loop to allow op to change parameters:
  201. X         * if a search evaluation converges (or errors out),
  202. X         * or if steps are done,
  203. X         * or if op hits any key.
  204. X         */
  205. X        newcir = 0;
  206. X        if (srchdone || nstep <= 0 || (chk_char()==0 && read_char()!=0)) {
  207. X        int nfld;
  208. X
  209. X        /* update screen with the current stuff if stopped during
  210. X         * unattended plotting or listing since last redraw_screen()
  211. X         * didn't.
  212. X         */
  213. X        if ((plot_ison() || listing_ison()) && nstep > 0)
  214. X            redraw_screen (1);
  215. X
  216. X        /* return nstep to default of 1 */
  217. X        if (nstep <= 0) {
  218. X            nstep = 1;
  219. X            print_nstep (0);
  220. X        }
  221. X
  222. X        /* change fields until END.
  223. X         * update all time fields if any are changed
  224. X         * and print NEW CIRCUMSTANCES if any have changed.
  225. X         * QUIT causes bye() to be called and we never return.
  226. X         */
  227. X        while(nfld = sel_fld(fld,alt_menumask()|F_CHG,prmpt,hlp)) {
  228. X            if (chg_fld ((char *)0, &nfld)) {
  229. X            mm_now (&now, 1);
  230. X            mm_newcir(1);
  231. X            newcir = 1;
  232. X            }
  233. X            fld = nfld;
  234. X        }
  235. X        if (nstep > 1)
  236. X            f_prompt (freerun);
  237. X        }
  238. X
  239. X        /* increment time only if op didn't change cirumstances */
  240. X        if (!newcir)
  241. X        inc_mjd (&now, tminc);
  242. X    }
  243. X
  244. X    return (0);
  245. X}
  246. X
  247. X/* read in ephem's configuration file, if any.
  248. X * if errors in file, call usage() (which exits).
  249. X * if use -d, require it; else try $EPHEMCFG and ephem.cfg but don't
  250. X *   complain if can't find these since, after all, one is not required.
  251. X * skip all lines that doesn't begin with an alpha char.
  252. X */
  253. Xstatic
  254. Xread_cfgfile()
  255. X{
  256. X    char buf[128];
  257. X    FILE *fp;
  258. X    char *fn;
  259. X
  260. X    /* open the config file. 
  261. X     * only REQUIRED if used -d option.
  262. X     * if succcessful, fn points to file name.
  263. X     */
  264. X    if (cfgfile) {
  265. X        fn = cfgfile;
  266. X        fp = fopen (fn, "r");
  267. X        if (!fp) {
  268. X        (void) sprintf (buf, "Can not open %s", fn);
  269. X        usage (buf);    /* does not return */
  270. X        }
  271. X    } else {
  272. X        fn = getenv ("EPHEMCFG");
  273. X        if (!fn)
  274. X        fn = cfgdef;
  275. X    }
  276. X    fp = fopen (fn, "r");
  277. X    if (!fp)
  278. X        return;    /* oh well; after all, it's not required */
  279. X
  280. X    while (fgets (buf, sizeof(buf), fp)) {
  281. X        if (!isalpha(buf[0]))
  282. X        continue;
  283. X        buf[strlen(buf)-1] = '\0';        /* discard trailing \n */
  284. X        if (crack_fieldset (buf) < 0) {
  285. X        char why[NC];
  286. X        (void) sprintf (why, "Bad field spec in %s: %s\n", fn, buf);
  287. X        usage (why);
  288. X        }
  289. X    }
  290. X    (void) fclose (fp);
  291. X}
  292. X
  293. X
  294. X/* draw all the stuff on the screen, using the current menu.
  295. X * if how_much == 0 then just update fields that need it;
  296. X * if how_much == 1 then redraw all fields;
  297. X * if how_much == 2 then erase the screen and redraw EVERYTHING.
  298. X */
  299. Xredraw_screen (how_much)
  300. Xint how_much;
  301. X{
  302. X    if (how_much == 2)
  303. X        c_erase();
  304. X
  305. X    /* print the single-step message if this is the last loop */
  306. X    if (nstep < 1)
  307. X        print_updating();
  308. X
  309. X    if (how_much == 2) {
  310. X        mm_borders();
  311. X        mm_labels();
  312. X        srch_prstate(1);
  313. X        plot_prstate(1);
  314. X        listing_prstate(1);
  315. X    }
  316. X
  317. X    /* if just updating changed fields while plotting or listing
  318. X     * unattended then suppress most screen updates except
  319. X     * always show nstep to show plot loops to go and
  320. X     * always show tminc to show search convergence progress.
  321. X     */
  322. X    print_nstep(how_much);
  323. X    print_tminc(how_much);
  324. X    print_spause(how_much);
  325. X    if (how_much == 0 && (plot_ison() || listing_ison()) && nstep > 0)
  326. X        f_off();
  327. X
  328. X    /* print all the time-related fields */
  329. X    mm_now (&now, how_much);
  330. X
  331. X    if (optwi)
  332. X        mm_twilight (&now, how_much);
  333. X
  334. X    /* print stuff on bottom menu */
  335. X    print_alt (how_much);
  336. X
  337. X    f_on();
  338. X}
  339. X
  340. X/* clean up and exit.
  341. X */
  342. Xvoid
  343. Xbye()
  344. X{
  345. X    c_erase();
  346. X    byetty();
  347. X    exit (0);
  348. X}
  349. X
  350. X/* this gets called when a floating point error occurs.
  351. X * we force a jump back into main() with looping terminated.
  352. X */
  353. Xstatic
  354. Xvoid
  355. Xon_fpe()
  356. X{
  357. X    extern void longjmp();
  358. X
  359. X    (void) signal (SIGFPE, on_fpe);
  360. X    f_msg ("Floating point error has occurred - computations aborted.");
  361. X    longjmp (fpe_err_jmp, 1);
  362. X}
  363. X
  364. Xusage(why)
  365. Xchar *why;
  366. X{
  367. X    /* don't advertise -s (silent) option */
  368. X    c_erase();
  369. X    f_string (1, 1, why);
  370. X    f_string (2, 1,
  371. X        "usage: [-c <configfile>] [-d <database>] [field=value ...]\r\n");
  372. X    byetty();
  373. X    exit (1);
  374. X}
  375. X
  376. X/* process the field specs from the command line.
  377. X * if trouble call usage() (which exits).
  378. X */
  379. Xstatic
  380. Xread_fieldargs (ac, av)
  381. Xint ac;        /* number of such specs */
  382. Xchar *av[];    /* array of strings in form <field_name value> */
  383. X{
  384. X    while (--ac >= 0) {
  385. X        char *fs = *av++;
  386. X        if (crack_fieldset (fs) < 0) {
  387. X        char why[NC];
  388. X        (void) sprintf (why, "Bad command line spec: %.*s",
  389. X                            sizeof(why)-26, fs);
  390. X        usage (why);
  391. X        }
  392. X    }
  393. X}
  394. X
  395. X/* process a field spec in buf, either from config file or argv.
  396. X * return 0 if recognized ok, else -1.
  397. X */
  398. Xstatic
  399. Xcrack_fieldset (buf)
  400. Xchar *buf;
  401. X{
  402. X#define    ARRAY_SIZ(a)    (sizeof(a)/sizeof((a)[0]))
  403. X#define    MAXKW        6    /* longest keyword, not counting trailing 0 */
  404. X    /* N.B. index of item is its case value, below.
  405. X     * N.B. if add an item, keep it no longer than MAXKW chars.
  406. X     */
  407. X    static char keywords[][MAXKW+1] = {
  408. X        /*  0 */    "LAT",
  409. X        /*  1 */    "LONG",
  410. X        /*  2 */    "UT",
  411. X        /*  3 */    "UD",
  412. X        /*  4 */    "TZONE",
  413. X        /*  5 */    "TZNAME",
  414. X        /*  6 */    "HEIGHT",
  415. X        /*  7 */    "NSTEP",
  416. X        /*  8 */    "PAUSE",
  417. X        /*  9 */    "STPSZ",
  418. X        /* 10 */    "TEMP",
  419. X        /* 11 */    "PRES",
  420. X        /* 12 */    "EPOCH",
  421. X        /* 13 */    "JD",
  422. X        /* 14 */    "OBJX",
  423. X        /* 15 */    "OBJY",
  424. X        /* 16 */    "PROPTS",
  425. X        /* 17 */    "MENU"
  426. X    };
  427. X    int i;
  428. X    int l;
  429. X    int f;
  430. X
  431. X    for (i = 0; i < ARRAY_SIZ(keywords); i++)
  432. X        if (strncmp (keywords[i], buf, l = strlen(keywords[i])) == 0) {
  433. X        buf += l+1;    /* skip keyword and its subsequent delimiter */
  434. X        break;
  435. X        }
  436. X
  437. X    switch (i) {
  438. X    case 0: f = rcfpack (R_LAT,C_LATV,0); (void) chg_fld (buf, &f);
  439. X        break;
  440. X    case 1: f = rcfpack (R_LONG,C_LONGV,0), (void) chg_fld (buf, &f);
  441. X        break;
  442. X    case 2: f = rcfpack (R_UT,C_UTV,0), (void) chg_fld (buf, &f);
  443. X        break;
  444. X    case 3: f = rcfpack (R_UD,C_UD,0), (void) chg_fld (buf, &f);
  445. X        break;
  446. X    case 4: f = rcfpack (R_TZONE,C_TZONEV,0), (void) chg_fld (buf, &f);
  447. X        break;
  448. X    case 5: f = rcfpack (R_TZN,C_TZN,0), (void) chg_fld (buf, &f);
  449. X        break;
  450. X    case 6: f = rcfpack (R_HEIGHT,C_HEIGHTV,0), (void) chg_fld (buf, &f);
  451. X        break;
  452. X    case 7: f = rcfpack (R_NSTEP,C_NSTEPV,0), (void) chg_fld (buf, &f);
  453. X        break;
  454. X    case 8: f = rcfpack (R_PAUSE,C_PAUSEV,0), (void) chg_fld (buf, &f);
  455. X        break;
  456. X    case 9: f = rcfpack (R_STPSZ,C_STPSZV,0), (void) chg_fld (buf, &f);
  457. X        break;
  458. X    case 10: f = rcfpack (R_TEMP,C_TEMPV,0), (void) chg_fld (buf, &f);
  459. X        break;
  460. X    case 11: f = rcfpack (R_PRES,C_PRESV,0), (void) chg_fld (buf, &f);
  461. X        break;
  462. X    case 12: f = rcfpack (R_EPOCH,C_EPOCHV,0), (void) chg_fld (buf, &f);
  463. X        break;
  464. X    case 13: f = rcfpack (R_JD,C_JDV,0), (void) chg_fld (buf, &f);
  465. X        break;
  466. X    case 14: (void) obj_filelookup (OBJX, buf);
  467. X        break;
  468. X    case 15: (void) obj_filelookup (OBJY, buf);
  469. X        break;
  470. X    case 16:
  471. X        if (buf[-1] != '+')
  472. X        optwi = oppl = 0;
  473. X        while (*buf)
  474. X        switch (*buf++) {
  475. X        case 'T': optwi = 1; break;
  476. X        case 'S': oppl |= (1<<SUN); break;
  477. X        case 'M': oppl |= (1<<MOON); break;
  478. X        case 'e': oppl |= (1<<MERCURY); break;
  479. X        case 'v': oppl |= (1<<VENUS); break;
  480. X        case 'm': oppl |= (1<<MARS); break;
  481. X        case 'j': case 'J': oppl |= (1<<JUPITER); break;
  482. X        case 's': oppl |= (1<<SATURN); break;
  483. X        case 'u': oppl |= (1<<URANUS); break;
  484. X        case 'n': oppl |= (1<<NEPTUNE); break;
  485. X        case 'p': oppl |= (1<<PLUTO); break;
  486. X        case 'x': oppl |= (1<<OBJX); obj_on(OBJX); break;
  487. X        case 'y': oppl |= (1<<OBJY); obj_on(OBJY); break;
  488. X        }
  489. X        break;
  490. X    case 17:
  491. X        if (strncmp (buf, "DATA", 4) == 0)
  492. X        altmenu_init (F_MNU1);
  493. X        else if (strncmp (buf, "RISET", 5) == 0)
  494. X        altmenu_init (F_MNU2);
  495. X        else if (strncmp (buf, "SEP", 3) == 0)
  496. X        altmenu_init (F_MNU3);
  497. X        else if (strncmp (buf, "JUP", 3) == 0)
  498. X        altmenu_init (F_MNUJ);
  499. X        break;
  500. X    default:
  501. X        return (-1);
  502. X    }
  503. X    return (0);
  504. X}
  505. X
  506. X/* react to the field at *fld according to the optional string input at bp.
  507. X * if bp is != 0 use it, else issue read_line() and use buffer.
  508. X * then sscanf the buffer and update the corresponding (global) variable(s)
  509. X * or do whatever a pick at that field should do.
  510. X * we might also change *fld if we want to change the current cursor location.
  511. X * return 1 if we change a field that invalidates any of the times or
  512. X * to update all related fields.
  513. X */
  514. Xstatic
  515. Xchg_fld (bp, fld)
  516. Xchar *bp;
  517. Xint *fld;
  518. X{
  519. X    char buf[NC];
  520. X    int deghrs = 0, mins = 0, secs = 0;
  521. X    int new = 0;
  522. X
  523. X    /* switch on just the row/col portion */
  524. X    switch (unpackrc(*fld)) {
  525. X    case rcfpack (R_ALTM, C_ALTM, 0):
  526. X        if (altmenu_setup() == 0) {
  527. X        print_updating();
  528. X        alt_erase();
  529. X        print_alt(2);
  530. X        }
  531. X        break;
  532. X    case rcfpack (R_JD, C_JDV, 0):
  533. X        if (!bp) {
  534. X        static char p[] = "Julian Date (or n for Now): ";
  535. X        f_prompt (p);
  536. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  537. X            break;
  538. X        bp = buf;
  539. X        }
  540. X        if (bp[0] == 'n' || bp[0] == 'N')
  541. X        time_fromsys (&now);
  542. X        else
  543. X        mjd = atof(bp) - 2415020L;
  544. X        set_t0 (&now);
  545. X        new = 1;
  546. X        break;
  547. X    case rcfpack (R_UD, C_UD, 0):
  548. X        if (!bp) {
  549. X        static char p[] = "utc date (m/d/y, or year.d, or n for Now): ";
  550. X        f_prompt (p);
  551. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  552. X            break;
  553. X        bp = buf;
  554. X        }
  555. X        if (bp[0] == 'n' || bp[0] == 'N')
  556. X        time_fromsys (&now);
  557. X        else {
  558. X        if (decimal_year(bp)) {
  559. X            double y = atof (bp);
  560. X            year_mjd (y, &mjd);
  561. X        } else {
  562. X            double day, newmjd0;
  563. X            int month, year;
  564. X            mjd_cal (mjd, &month, &day, &year); /* init with now */
  565. X            f_sscandate (bp, &month, &day, &year);
  566. X            cal_mjd (month, day, year, &newmjd0);
  567. X            /* if don't give a fractional part to days
  568. X             * then retain current hours.
  569. X             */
  570. X            if ((long)day == day)
  571. X            mjd = newmjd0 + mjd_hr(mjd)/24.0;
  572. X            else
  573. X            mjd = newmjd0;
  574. X        }
  575. X        }
  576. X        set_t0 (&now);
  577. X        new = 1;
  578. X        break;
  579. X    case rcfpack (R_UT, C_UTV, 0):
  580. X        if (!bp) {
  581. X        static char p[] = "utc time (h:m:s, or n for Now): ";
  582. X        f_prompt (p);
  583. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  584. X            break;
  585. X        bp = buf;
  586. X        }
  587. X        if (bp[0] == 'n' || bp[0] == 'N')
  588. X        time_fromsys (&now);
  589. X        else {
  590. X        double newutc = (mjd-mjd_day(mjd)) * 24.0;
  591. X        f_dec_sexsign (newutc, °hrs, &mins, &secs);
  592. X        f_sscansex (bp, °hrs, &mins, &secs);
  593. X        sex_dec (deghrs, mins, secs, &newutc);
  594. X        mjd = mjd_day(mjd) + newutc/24.0;
  595. X        }
  596. X        set_t0 (&now);
  597. X        new = 1;
  598. X        break;
  599. X    case rcfpack (R_LD, C_LD, 0):
  600. X        if (!bp) {
  601. X        static char p[] = "local date (m/d/y, or year.d, n for Now): ";
  602. X        f_prompt (p);
  603. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  604. X            break;
  605. X        bp = buf;
  606. X        }
  607. X        if (bp[0] == 'n' || bp[0] == 'N')
  608. X        time_fromsys (&now);
  609. X        else {
  610. X        if (decimal_year(bp)) {
  611. X            double y = atof (bp);
  612. X            year_mjd (y, &mjd);
  613. X            mjd += tz/24.0;
  614. X        } else {
  615. X            double day, newlmjd0;
  616. X            int month, year;
  617. X            mjd_cal (mjd-tz/24.0, &month, &day, &year); /* now */
  618. X            f_sscandate (bp, &month, &day, &year);
  619. X            cal_mjd (month, day, year, &newlmjd0);
  620. X            /* if don't give a fractional part to days
  621. X             * then retain current hours.
  622. X             */
  623. X            if ((long)day == day)
  624. X            mjd = newlmjd0 + mjd_hr(mjd-tz/24.0)/24.0;
  625. X            else
  626. X            mjd = newlmjd0;
  627. X            mjd += tz/24.0;
  628. X        }
  629. X        }
  630. X        set_t0 (&now);
  631. X        new = 1;
  632. X        break;
  633. X    case rcfpack (R_LT, C_LT, 0):
  634. X        if (!bp) {
  635. X        static char p[] = "local time (h:m:s, or n for Now): ";
  636. X        f_prompt (p);
  637. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  638. X            break;
  639. X        bp = buf;
  640. X        }
  641. X        if (bp[0] == 'n' || bp[0] == 'N')
  642. X        time_fromsys (&now);
  643. X        else {
  644. X        double newlt = (mjd-mjd_day(mjd)) * 24.0 - tz;
  645. X        range (&newlt, 24.0);
  646. X        f_dec_sexsign (newlt, °hrs, &mins, &secs);
  647. X        f_sscansex (bp, °hrs, &mins, &secs);
  648. X        sex_dec (deghrs, mins, secs, &newlt);
  649. X        mjd = mjd_day(mjd-tz/24.0) + (newlt + tz)/24.0;
  650. X        }
  651. X        set_t0 (&now);
  652. X        new = 1;
  653. X        break;
  654. X    case rcfpack (R_LST, C_LSTV, 0):
  655. X        if (!bp) {
  656. X        static char p[] = "local sidereal time (h:m:s, or n for Now): ";
  657. X        f_prompt (p);
  658. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  659. X            break;
  660. X        bp = buf;
  661. X        }
  662. X        if (bp[0] == 'n' || bp[0] == 'N')
  663. X        time_fromsys (&now);
  664. X        else {
  665. X        double lst, utc;
  666. X        now_lst (&now, &lst);
  667. X        f_dec_sexsign (lst, °hrs, &mins, &secs);
  668. X        f_sscansex (bp, °hrs, &mins, &secs);
  669. X        sex_dec (deghrs, mins, secs, &lst);
  670. X        lst -= radhr(lng); /* convert to gst */
  671. X        range (&lst, 24.0);
  672. X        gst_utc (mjd_day(mjd), lst, &utc);
  673. X        mjd = mjd_day(mjd) + utc/24.0;
  674. X        }
  675. X        set_t0 (&now);
  676. X        new = 1;
  677. X        break;
  678. X    case rcfpack (R_TZN, C_TZN, 0):
  679. X        if (!bp) {
  680. X        static char p[] = "timezone abbreviation (3 char max): ";
  681. X        f_prompt (p);
  682. X        if (read_line (buf, 3) <= 0)
  683. X            break;
  684. X        bp = buf;
  685. X        }
  686. X        (void) strncpy (tznm, bp, sizeof(tznm)-1);
  687. X        new = 1;
  688. X        break;
  689. X    case rcfpack (R_TZONE, C_TZONEV, 0):
  690. X        if (!bp) {
  691. X        static char p[] = "hours behind utc: ";
  692. X        f_prompt (p);
  693. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  694. X            break;
  695. X        bp = buf;
  696. X        }
  697. X        f_dec_sexsign (tz, °hrs, &mins, &secs);
  698. X        f_sscansex (bp, °hrs, &mins, &secs);
  699. X        sex_dec (deghrs, mins, secs, &tz);
  700. X        new = 1;
  701. X        break;
  702. X    case rcfpack (R_LONG, C_LONGV, 0):
  703. X        if (!bp) {
  704. X        static char p[] = "longitude (+ west) (d:m:s): ";
  705. X        f_prompt (p);
  706. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  707. X            break;
  708. X        bp = buf;
  709. X        }
  710. X        f_dec_sexsign (-raddeg(lng), °hrs, &mins, &secs);
  711. X        f_sscansex (bp, °hrs, &mins, &secs);
  712. X        sex_dec (deghrs, mins, secs, &lng);
  713. X        lng = degrad (-lng);         /* want - radians west */
  714. X        new = 1;
  715. X        break;
  716. X    case rcfpack (R_LAT, C_LATV, 0):
  717. X        if (!bp) {
  718. X        static char p[] = "latitude (+ north) (d:m:s): ";
  719. X        f_prompt (p);
  720. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  721. X            break;
  722. X        bp = buf;
  723. X        }
  724. X        f_dec_sexsign (raddeg(lat), °hrs, &mins, &secs);
  725. X        f_sscansex (bp, °hrs, &mins, &secs);
  726. X        sex_dec (deghrs, mins, secs, &lat);
  727. X        lat = degrad (lat);
  728. X        new = 1;
  729. X        break;
  730. X    case rcfpack (R_HEIGHT, C_HEIGHTV, 0):
  731. X        if (!bp) {
  732. X        static char p[] = "height above sea level (ft): ";
  733. X        f_prompt (p);
  734. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  735. X            break;
  736. X        bp = buf;
  737. X        }
  738. X        if (sscanf (bp, "%lf", &height) == 1) {
  739. X        height /= 2.093e7; /*convert ft to earth radii above sea level*/
  740. X        new = 1;
  741. X        }
  742. X        break;
  743. X    case rcfpack (R_NSTEP, C_NSTEPV, 0):
  744. X        if (!bp) {
  745. X        static char p[] = "number of steps to run: ";
  746. X        f_prompt (p);
  747. X        if (read_line (buf, 8) <= 0)
  748. X            break;
  749. X        bp = buf;
  750. X        }
  751. X        (void) sscanf (bp, "%d", &nstep);
  752. X        print_nstep (0);
  753. X        break;
  754. X    case rcfpack (R_PAUSE, C_PAUSEV, 0):
  755. X        if (!bp) {
  756. X        static char p[] = "seconds to pause between steps: ";
  757. X        f_prompt (p);
  758. X        if (read_line (buf, 8) <= 0)
  759. X            break;
  760. X        bp = buf;
  761. X        }
  762. X        (void) sscanf (bp, "%d", &spause);
  763. X        print_spause (0);
  764. X        break;
  765. X    case rcfpack (R_TEMP, C_TEMPV, 0):
  766. X        if (!bp) {
  767. X        static char p[] = "temperature (deg.F): ";
  768. X        f_prompt (p);
  769. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  770. X            break;
  771. X        bp = buf;
  772. X        }
  773. X        if (sscanf (bp, "%lf", &temp) == 1) {
  774. X        temp = 5./9.*(temp - 32.0);    /* want degs C */
  775. X        new = 1;
  776. X        }
  777. X        break;
  778. X    case rcfpack (R_PRES, C_PRESV, 0):
  779. X        if (!bp) {
  780. X        static char p[] =
  781. X            "atmos pressure (in. Hg; 0 for no refraction correction): ";
  782. X        f_prompt (p);
  783. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  784. X            break;
  785. X        bp = buf;
  786. X        }
  787. X        if (sscanf (bp, "%lf", &pressure) == 1) {
  788. X        pressure *= 33.86;        /* want mBar */
  789. X        new = 1;
  790. X        }
  791. X        break;
  792. X    case rcfpack (R_EPOCH, C_EPOCHV, 0):
  793. X        if (!bp) {
  794. X        static char p[] = "epoch (year, or e for Equinox of Date): ";
  795. X        f_prompt (p);
  796. X        if (read_line (buf, PW-strlen(p)) <= 0)
  797. X            break;
  798. X        bp = buf;
  799. X        }
  800. X        if (bp[0] == 'e' || bp[0] == 'E')
  801. X        epoch = EOD;
  802. X        else {
  803. X        double e;
  804. X        e = atof(bp);
  805. X        year_mjd (e, &epoch);
  806. X        }
  807. X        new = 1;
  808. X        break;
  809. X    case rcfpack (R_STPSZ, C_STPSZV, 0):
  810. X        if (!bp) {
  811. X        static char p[] =
  812. X            "step size increment (h:m:s, or <x>d for x days, or r for RTC): ";
  813. X        f_prompt (p);
  814. X        if (read_line (buf, PW-sizeof(p)) <= 0)
  815. X            break;
  816. X        bp = buf;
  817. X        }
  818. X        if (bp[0] == 'r' || bp[0] == 'R')
  819. X        tminc = RTC;
  820. X        else {
  821. X        int last = strlen (bp) - 1;
  822. X        if (bp[last] == 'd') {
  823. X            /* ends in d so treat as a number of days */
  824. X            double x;
  825. X            if (sscanf (bp, "%lf", &x) == 1)
  826. X            tminc = x * 24.0;
  827. X        } else {
  828. X            if (tminc == RTC)
  829. X            deghrs = mins = secs = 0;
  830. X            else
  831. X            f_dec_sexsign (tminc, °hrs, &mins, &secs);
  832. X            f_sscansex (bp, °hrs, &mins, &secs);
  833. X            sex_dec (deghrs, mins, secs, &tminc);
  834. X        }
  835. X        }
  836. X        print_tminc(0);
  837. X        set_t0 (&now);
  838. X        break;
  839. X    case rcfpack (R_PLOT, C_PLOT, 0):
  840. X        plot_setup();
  841. X        if (plot_ison())
  842. X        new = 1;
  843. X        break;
  844. X    case rcfpack (R_LISTING, C_LISTING, 0):
  845. X        listing_setup();
  846. X        if (listing_ison())
  847. X        new = 1;
  848. X        break;
  849. X    case rcfpack (R_WATCH, C_WATCH, 0):
  850. X        watch (&now, tminc, oppl);
  851. X        /* set new reference time to what watch left it.
  852. X         * no need to set new since watch just did a redraw.
  853. X         */
  854. X        set_t0 (&now);
  855. X        break;
  856. X    case rcfpack (R_DAWN, C_DAWN, 0):
  857. X    case rcfpack (R_DUSK, C_DUSK, 0):
  858. X    case rcfpack (R_LON, C_LON, 0):
  859. X        if (optwi ^= 1) {
  860. X        print_updating();
  861. X        mm_twilight (&now, 1);
  862. X        } else {
  863. X        f_blanks (R_DAWN, C_DAWNV, 5);
  864. X        f_blanks (R_DUSK, C_DUSKV, 5);
  865. X        f_blanks (R_LON, C_LONV, 5);
  866. X        }
  867. X        break;
  868. X    case rcfpack (R_SRCH, C_SRCH, 0):
  869. X        srch_setup();
  870. X        if (srch_ison())
  871. X        new = 1;
  872. X        break;
  873. X    case rcfpack (R_SUN, C_OBJ, 0):
  874. X        toggle_body (SUN);
  875. X        break;
  876. X    case rcfpack (R_SUN, C_CONSTEL, 0):
  877. X        if (oppl & (1<<SUN))
  878. X        constellation_msg (SUN, &now);
  879. X        break;
  880. X    case rcfpack (R_MOON, C_OBJ, 0):
  881. X        toggle_body (MOON);
  882. X        break;
  883. X    case rcfpack (R_MOON, C_CONSTEL, 0):
  884. X        if (oppl & (1<<MOON))
  885. X        constellation_msg (MOON, &now);
  886. X        break;
  887. X    case rcfpack (R_MERCURY, C_OBJ, 0):
  888. X        toggle_body (MERCURY);
  889. X        break;
  890. X    case rcfpack (R_MERCURY, C_CONSTEL, 0):
  891. X        if (oppl & (1<<MERCURY))
  892. X        constellation_msg (MERCURY, &now);
  893. X        break;
  894. X    case rcfpack (R_VENUS, C_OBJ, 0):
  895. X        toggle_body (VENUS);
  896. X        break;
  897. X    case rcfpack (R_VENUS, C_CONSTEL, 0):
  898. X        if (oppl & (1<<VENUS))
  899. X        constellation_msg (VENUS, &now);
  900. X        break;
  901. X    case rcfpack (R_MARS, C_OBJ, 0):
  902. X        toggle_body (MARS);
  903. X        break;
  904. X    case rcfpack (R_MARS, C_CONSTEL, 0):
  905. X        if (oppl & (1<<MARS))
  906. X        constellation_msg (MARS, &now);
  907. X        break;
  908. X    case rcfpack (R_JUPITER, C_OBJ, 0):
  909. X        toggle_body (JUPITER);
  910. X        break;
  911. X    case rcfpack (R_JUPITER, C_CONSTEL, 0):
  912. X        if (oppl & (1<<JUPITER))
  913. X        constellation_msg (JUPITER, &now);
  914. X        break;
  915. X    case rcfpack (R_JUPITER, C_XTRA, 0):
  916. X        if (oppl & (1<<JUPITER)) {
  917. X        print_updating();
  918. X        alt_erase();
  919. X        altmenu_init (F_MNUJ);
  920. X        print_alt (2);
  921. X        *fld = rcfpack(R_NSTEP, C_NSTEPV, 0);
  922. X        }
  923. X        break;
  924. X    case rcfpack (R_SATURN, C_OBJ, 0):
  925. X        toggle_body (SATURN);
  926. X        break;
  927. X    case rcfpack (R_SATURN, C_CONSTEL, 0):
  928. X        if (oppl & (1<<SATURN))
  929. X        constellation_msg (SATURN, &now);
  930. X        break;
  931. X    case rcfpack (R_URANUS, C_OBJ, 0):
  932. X        toggle_body (URANUS);
  933. X        break;
  934. X    case rcfpack (R_URANUS, C_CONSTEL, 0):
  935. X        if (oppl & (1<<URANUS))
  936. X        constellation_msg (URANUS, &now);
  937. X        break;
  938. X    case rcfpack (R_NEPTUNE, C_OBJ, 0):
  939. X        toggle_body (NEPTUNE);
  940. X        break;
  941. X    case rcfpack (R_NEPTUNE, C_CONSTEL, 0):
  942. X        if (oppl & (1<<NEPTUNE))
  943. X        constellation_msg (NEPTUNE, &now);
  944. X        break;
  945. X    case rcfpack (R_PLUTO, C_OBJ, 0):
  946. X        toggle_body (PLUTO);
  947. X        break;
  948. X    case rcfpack (R_PLUTO, C_CONSTEL, 0):
  949. X        if (oppl & (1<<PLUTO))
  950. X        constellation_msg (PLUTO, &now);
  951. X        break;
  952. X    case rcfpack (R_OBJX, C_OBJ, 0):
  953. X        /* this might change which columns are used so erase all when
  954. X         * returns and redraw if still on.
  955. X         */
  956. X        obj_setup (OBJX);
  957. X        alt_nobody (OBJX);
  958. X        if (obj_ison (OBJX)) {
  959. X        oppl |= 1 << OBJX;
  960. X        print_updating();
  961. X        alt_body (OBJX, 1, &now);
  962. X        } else
  963. X        oppl &= ~(1 << OBJX);    /* already erased; just clear flag */
  964. X        break;
  965. X    case rcfpack (R_OBJX, C_CONSTEL, 0):
  966. X        if (oppl & (1<<OBJX))
  967. X        constellation_msg (OBJX, &now);
  968. X        break;
  969. X    case rcfpack (R_OBJY, C_OBJ, 0):
  970. X        /* this might change which columns are used so erase all when
  971. X         * returns and redraw if still on.
  972. X         */
  973. X        obj_setup (OBJY);
  974. X        alt_nobody (OBJY);
  975. X        if (obj_ison (OBJY)) {
  976. X        oppl |= 1 << OBJY;
  977. X        print_updating();
  978. X        alt_body (OBJY, 1, &now);
  979. X        } else
  980. X        oppl &= ~(1 << OBJY);    /* already erased; just clear flag */
  981. X        break;
  982. X    case rcfpack (R_OBJY, C_CONSTEL, 0):
  983. X        if (oppl & (1<<OBJY))
  984. X        constellation_msg (OBJY, &now);
  985. X        break;
  986. X    }
  987. X
  988. X    return (new);
  989. X}
  990. X
  991. Xstatic
  992. Xprint_tminc(force)
  993. Xint force;
  994. X{
  995. X    static double last = -123.456;    /* anything unlikely */
  996. X
  997. X    if (force || tminc != last) {
  998. X        if (tminc == RTC)
  999. X        f_string (R_STPSZ, C_STPSZV, " RT CLOCK");
  1000. X        else if (fabs(tminc) >= 24.0)
  1001. X        f_double (R_STPSZ, C_STPSZV, "%6.4g dy", tminc/24.0);
  1002. X        else
  1003. X        f_signtime (R_STPSZ, C_STPSZV, tminc);
  1004. X        last = tminc;
  1005. X    }
  1006. X}
  1007. X
  1008. X/* print stuff on bottom menu */
  1009. Xstatic
  1010. Xprint_alt (howmuch)
  1011. Xint howmuch;
  1012. X{
  1013. X    if (howmuch == 2)
  1014. X        alt_labels();
  1015. X    if (alt_menumask() == F_MNUJ)
  1016. X        altj_display (howmuch, &now);
  1017. X    else {
  1018. X        int p;
  1019. X        for (p = nxtbody(-1); p != -1; p = nxtbody(p))
  1020. X        if (oppl & (1<<p))
  1021. X            alt_body (p, howmuch, &now);
  1022. X    }
  1023. X}
  1024. X
  1025. Xprint_updating()
  1026. X{
  1027. X    f_prompt ("Updating...");
  1028. X}
  1029. X
  1030. Xstatic
  1031. Xprint_nstep(force)
  1032. Xint force;
  1033. X{
  1034. X    static int last;
  1035. X
  1036. X    if (force || nstep != last) {
  1037. X        char buf[16];
  1038. X        (void) sprintf (buf, "%8d", nstep);
  1039. X        f_string (R_NSTEP, C_NSTEPV, buf);
  1040. X        last = nstep;
  1041. X    }
  1042. X}
  1043. X
  1044. Xstatic
  1045. Xprint_spause(force)
  1046. Xint force;
  1047. X{
  1048. X    static int last;
  1049. X
  1050. X    if (force || spause != last) {
  1051. X        char buf[16];
  1052. X        (void) sprintf (buf, "%8d", spause);
  1053. X        f_string (R_PAUSE, C_PAUSEV, buf);
  1054. X        last = spause;
  1055. X    }
  1056. X}
  1057. X
  1058. X/* if not plotting/listing/searching then sleep spause seconds.
  1059. X * if time is being based on the real-time clock, sync on the next
  1060. X *   integral multiple of spause seconds after the minute.
  1061. X * check for keyboard action once each second to let it break out early.
  1062. X */
  1063. Xslp_sync()
  1064. X{
  1065. X    extern long time();
  1066. X
  1067. X    if (spause > 0 && !plot_ison() && !srch_ison() && !listing_ison()) {
  1068. X        int n;
  1069. X        if (tminc == RTC) {
  1070. X        long t;
  1071. X        (void) time (&t);
  1072. X        n = spause - (t % spause);
  1073. X        } else 
  1074. X        n = spause;
  1075. X        while (--n >= 0)
  1076. X        if (chk_char() == 0)
  1077. X            break;
  1078. X        else
  1079. X            (void) sleep (1);
  1080. X    }
  1081. X}
  1082. X
  1083. Xstatic
  1084. Xtoggle_body (p)
  1085. Xint p;
  1086. X{
  1087. X    if ((oppl ^= (1<<p)) & (1<<p)) {
  1088. X        print_updating();
  1089. X        alt_body (p, 1, &now);
  1090. X    } else
  1091. X        alt_nobody (p);
  1092. X}
  1093. END_OF_FILE
  1094.   if test 26117 -ne `wc -c <'main.c'`; then
  1095.     echo shar: \"'main.c'\" unpacked with wrong size!
  1096.   fi
  1097.   # end of 'main.c'
  1098. fi
  1099. if test -f 'mainmenu.c' -a "${1}" != "-c" ; then 
  1100.   echo shar: Will not clobber existing file \"'mainmenu.c'\"
  1101. else
  1102.   echo shar: Extracting \"'mainmenu.c'\" \(6349 characters\)
  1103.   sed "s/^X//" >'mainmenu.c' <<'END_OF_FILE'
  1104. X/* printing routines for the main (upper) screen.
  1105. X */
  1106. X
  1107. X#include <stdio.h>
  1108. X#include <math.h>
  1109. X#include "astro.h"
  1110. X#include "circum.h"
  1111. X#include "screen.h"
  1112. X
  1113. X/* #define PC_GRAPHICS */
  1114. X#ifdef PC_GRAPHICS
  1115. X#define    JOINT    207
  1116. X#define    VERT    179
  1117. X#define    HORIZ    205
  1118. X#else
  1119. X#define    JOINT    '-'
  1120. X#define    VERT    '|'
  1121. X#define    HORIZ    '-'
  1122. X#endif
  1123. X
  1124. Xmm_borders()
  1125. X{
  1126. X    char line[NC+1], *lp;
  1127. X    register i;
  1128. X
  1129. X    lp = line;
  1130. X    for (i = 0; i < NC; i++)
  1131. X        *lp++ = HORIZ;
  1132. X    *lp = '\0';
  1133. X    f_string (R_PLANTAB-1, 1, line);
  1134. X    for (i = R_TOP; i < R_PLANTAB-1; i++)
  1135. X        f_char (i, COL2-2, VERT);
  1136. X    f_char (R_PLANTAB-1, COL2-2, JOINT);
  1137. X    for (i = R_TOP; i < R_PLANTAB-1; i++)
  1138. X        f_char (i, COL3-2, VERT);
  1139. X    f_char (R_PLANTAB-1, COL3-2, JOINT);
  1140. X    for (i = R_LST; i < R_PLANTAB-1; i++)
  1141. X        f_char (i, COL4-2, VERT);
  1142. X    f_char (R_PLANTAB-1, COL4-2, JOINT);
  1143. X}
  1144. X
  1145. X/* print the permanent labels on the top menu */
  1146. Xmm_labels()
  1147. X{
  1148. X    f_string (R_TZN,    C_TZN,        "LT");
  1149. X    f_string (R_UT,        C_UT,        "UTC");
  1150. X    f_string (R_JD,        C_JD,        "JulianDate");
  1151. X    f_string (R_LISTING,    C_LISTING,    "Listing");
  1152. X    f_string (R_WATCH,    C_WATCH,    "Watch");
  1153. X    f_string (R_SRCH,    C_SRCH,        "Search");
  1154. X    f_string (R_PLOT,    C_PLOT,        "Plot");
  1155. X    f_string (R_ALTM,    C_ALTM,        "Menu");
  1156. X
  1157. X    f_string (R_LST,    C_LST,        "LST");
  1158. X    f_string (R_DAWN,    C_DAWN,        "Dawn");
  1159. X    f_string (R_DUSK,    C_DUSK,        "Dusk");
  1160. X    f_string (R_LON,    C_LON,        "NiteLn");
  1161. X    f_string (R_PAUSE,    C_PAUSE,    "Pause");
  1162. X    f_string (R_NSTEP,    C_NSTEP,    "NStep");
  1163. X    f_string (R_STPSZ,    C_STPSZ,    "StpSz");
  1164. X
  1165. X    f_string (R_LAT,    C_LAT,        "Lat");
  1166. X    f_string (R_LONG,    C_LONG,        "Long");
  1167. X    f_string (R_HEIGHT,    C_HEIGHT,    "Elev");
  1168. X    f_string (R_TEMP,    C_TEMP,        "Temp");
  1169. X    f_string (R_PRES,    C_PRES,        "AtmPr");
  1170. X    f_string (R_TZONE,    C_TZONE,    "TZ");
  1171. X    f_string (R_EPOCH,    C_EPOCH,    "Epoch");
  1172. X}
  1173. X
  1174. X/* print all the time/date/where related stuff: the Now structure.
  1175. X * print in a nice order, based on the field locations, as much as possible.
  1176. X */
  1177. Xmm_now (np, all)
  1178. XNow *np;
  1179. Xint all;
  1180. X{
  1181. X    char buf[32];
  1182. X    double lmjd = mjd - tz/24.0;
  1183. X    double jd = mjd + 2415020L;
  1184. X    double tmp;
  1185. X
  1186. X    (void) sprintf (buf, "%-3.3s", tznm);
  1187. X    f_string (R_TZN, C_TZN, buf);
  1188. X    f_time (R_LT, C_LT, mjd_hr(lmjd));
  1189. X    f_date (R_LD, C_LD, lmjd);
  1190. X
  1191. X    f_time (R_UT, C_UTV, mjd_hr(mjd));
  1192. X    f_date (R_UD, C_UD, mjd);
  1193. X
  1194. X    (void) sprintf (buf, "%14.5f", jd);
  1195. X    (void) flog_log (R_JD, C_JDV, jd, buf);
  1196. X    f_string (R_JD, C_JDV, buf);
  1197. X
  1198. X    now_lst (np, &tmp);
  1199. X    f_time (R_LST, C_LSTV, tmp);
  1200. X
  1201. X    if (all) {
  1202. X        f_gangle (R_LAT, C_LATV, lat);
  1203. X        f_gangle (R_LONG, C_LONGV, -lng);    /* + west */
  1204. X
  1205. X        tmp = height * 2.093e7;    /* want to see ft, not earth radii */
  1206. X        (void) sprintf (buf, "%5g ft", tmp);
  1207. X        (void) flog_log (R_HEIGHT, C_HEIGHTV, tmp, buf);
  1208. X        f_string (R_HEIGHT, C_HEIGHTV, buf);
  1209. X
  1210. X        tmp = 9./5.*temp + 32.0;     /* want to see degrees F, not C */
  1211. X        (void) sprintf (buf, "%6g F", tmp);
  1212. X        (void) flog_log (R_TEMP, C_TEMPV, tmp, buf);
  1213. X        f_string (R_TEMP, C_TEMPV, buf);
  1214. X
  1215. X        tmp = pressure / 33.86;    /* want to see in. Hg, not mBar */
  1216. X        (void) sprintf (buf, "%5.2f in", tmp);
  1217. X        (void) flog_log (R_PRES, C_PRESV, tmp, buf);
  1218. X        f_string (R_PRES, C_PRESV, buf);
  1219. X
  1220. X        f_signtime (R_TZONE, C_TZONEV, tz);
  1221. X
  1222. X        if (epoch == EOD)
  1223. X        f_string (R_EPOCH, C_EPOCHV, "(OfDate)");
  1224. X        else {
  1225. X        mjd_year (epoch, &tmp);
  1226. X        f_double (R_EPOCH, C_EPOCHV, "%8.1f", tmp);
  1227. X        }
  1228. X    }
  1229. X
  1230. X    /* print the calendar for local day, if new month/year.  */
  1231. X    mm_calendar (np, all > 1);
  1232. X}
  1233. X
  1234. X/* display dawn/dusk/length-of-night times.
  1235. X */
  1236. Xmm_twilight (np, force)
  1237. XNow *np;
  1238. Xint force;
  1239. X{
  1240. X    double dusk, dawn;
  1241. X    double tmp;
  1242. X    int status;
  1243. X
  1244. X    if (!twilight_cir (np, &dawn, &dusk, &status) && !force)
  1245. X        return;
  1246. X
  1247. X    if (status != 0) {
  1248. X        f_blanks (R_DAWN, C_DAWNV, 5);
  1249. X        f_blanks (R_DUSK, C_DUSKV, 5);
  1250. X        f_string (R_LON, C_LONV, "-----");
  1251. X        return;
  1252. X    }
  1253. X
  1254. X    f_mtime (R_DAWN, C_DAWNV, dawn);
  1255. X    f_mtime (R_DUSK, C_DUSKV, dusk);
  1256. X    tmp = dawn - dusk; range (&tmp, 24.0);
  1257. X    f_mtime (R_LON, C_LONV, tmp);
  1258. X}
  1259. X
  1260. Xmm_newcir (y)
  1261. Xint y;
  1262. X{
  1263. X    static char ncmsg[] = "NEW CIRCUMSTANCES";
  1264. X    static char nomsg[] = "                 ";
  1265. X    static int last_y = -1;
  1266. X
  1267. X    if (y != last_y) {
  1268. X        f_string (R_NEWCIR, C_NEWCIR, y ? ncmsg : nomsg);
  1269. X        last_y = y;
  1270. X    }
  1271. X}
  1272. X
  1273. Xstatic
  1274. Xmm_calendar (np, force)
  1275. XNow *np;
  1276. Xint force;
  1277. X{
  1278. X    static char *mnames[] = {
  1279. X        "January", "February", "March", "April", "May", "June",
  1280. X        "July", "August", "September", "October", "November", "December"
  1281. X    };
  1282. X    static int last_m, last_y;
  1283. X    static double last_tz = -100;
  1284. X    char str[64];
  1285. X    int m, y;
  1286. X    double d;
  1287. X    int f, nd;
  1288. X    int r;
  1289. X    double jd0;
  1290. X
  1291. X    /* get local m/d/y. do nothing if still same month and not forced. */
  1292. X    mjd_cal (mjd_day(mjd-tz/24.0), &m, &d, &y);
  1293. X    if (m == last_m && y == last_y && tz == last_tz && !force)
  1294. X        return;
  1295. X    last_m = m;
  1296. X    last_y = y;
  1297. X    last_tz = tz;
  1298. X
  1299. X    /* find day of week of first day of month */
  1300. X    cal_mjd (m, 1.0, y, &jd0);
  1301. X    mjd_dow (jd0, &f);
  1302. X    if (f < 0) {
  1303. X        /* can't figure it out - too hard before Gregorian */
  1304. X        int i;
  1305. X        for (i = 8; --i >= 0; )
  1306. X        f_string (R_CAL+i, C_CAL, "                    ");
  1307. X        return;
  1308. X    }
  1309. X
  1310. X    /* print header */
  1311. X    f_blanks (R_CAL, C_CAL, 20);
  1312. X    (void) sprintf (str, "%s %4d", mnames[m-1], y);
  1313. X    f_string (R_CAL, C_CAL + (20 - (strlen(mnames[m-1]) + 5))/2, str);
  1314. X    f_string (R_CAL+1, C_CAL, "Su Mo Tu We Th Fr Sa");
  1315. X
  1316. X    /* find number of days in this month */
  1317. X    mjd_dpm (jd0, &nd);
  1318. X
  1319. X    /* print the calendar */
  1320. X    for (r = 0; r < 6; r++) {
  1321. X        char row[7*3+1], *rp = row;
  1322. X        int c;
  1323. X        for (c = 0; c < 7; c++) {
  1324. X        int i = r*7+c;
  1325. X        if (i < f || i >= f + nd)
  1326. X            (void) sprintf (rp, "   ");
  1327. X        else
  1328. X            (void) sprintf (rp, "%2d ", i-f+1);
  1329. X        rp += 3;
  1330. X        }
  1331. X        row[sizeof(row)-2] = '\0';    /* don't print last blank; causes wrap*/
  1332. X        f_string (R_CAL+2+r, C_CAL, row);
  1333. X    }
  1334. X
  1335. X    /* over print the new and full moons for this month.
  1336. X     * TODO: don't really know which dates to use here (see moonnf())
  1337. X     *   so try several to be fairly safe. have to go back to 4/29/1988
  1338. X     *   to find the full moon on 5/1 for example.
  1339. X     */
  1340. X    mm_nfmoon (jd0-3, tz, m, f);
  1341. X    mm_nfmoon (jd0+15, tz, m, f);
  1342. X}
  1343. X
  1344. Xstatic
  1345. Xmm_nfmoon (jd, tzone, m, f)
  1346. Xdouble jd, tzone;
  1347. Xint m, f;
  1348. X{
  1349. X    static char nm[] = "NM", fm[] = "FM";
  1350. X    double dm;
  1351. X    int mm, ym;
  1352. X    double jdn, jdf;
  1353. X    int di;
  1354. X
  1355. X    moonnf (jd, &jdn, &jdf);
  1356. X    mjd_cal (jdn-tzone/24.0, &mm, &dm, &ym);
  1357. X    if (m == mm) {
  1358. X        di = dm + f - 1;
  1359. X        f_string (R_CAL+2+di/7, C_CAL+3*(di%7), nm);
  1360. X    }
  1361. X    mjd_cal (jdf-tzone/24.0, &mm, &dm, &ym);
  1362. X    if (m == mm) {
  1363. X        di = dm + f - 1;
  1364. X        f_string (R_CAL+2+di/7, C_CAL+3*(di%7), fm);
  1365. X    }
  1366. X}
  1367. END_OF_FILE
  1368.   if test 6349 -ne `wc -c <'mainmenu.c'`; then
  1369.     echo shar: \"'mainmenu.c'\" unpacked with wrong size!
  1370.   fi
  1371.   # end of 'mainmenu.c'
  1372. fi
  1373. if test -f 'plans.c' -a "${1}" != "-c" ; then 
  1374.   echo shar: Will not clobber existing file \"'plans.c'\"
  1375. else
  1376.   echo shar: Extracting \"'plans.c'\" \(17647 characters\)
  1377.   sed "s/^X//" >'plans.c' <<'END_OF_FILE'
  1378. X#include <stdio.h>
  1379. X#include <math.h>
  1380. X#include "astro.h"
  1381. X
  1382. X#define    TWOPI        (2*PI)
  1383. X#define    mod2PI(x)    ((x) - (long)((x)/TWOPI)*TWOPI)
  1384. X
  1385. X/* given a modified Julian date, mjd, and a planet, p, find:
  1386. X *   lpd0: heliocentric longitude, 
  1387. X *   psi0: heliocentric latitude,
  1388. X *   rp0:  distance from the sun to the planet, 
  1389. X *   rho0: distance from the Earth to the planet,
  1390. X *         none corrected for light time, ie, they are the true values for the
  1391. X *         given instant.
  1392. X *   lam:  geocentric ecliptic longitude, 
  1393. X *   bet:  geocentric ecliptic latitude,
  1394. X *         each corrected for light time, ie, they are the apparent values as
  1395. X *       seen from the center of the Earth for the given instant.
  1396. X *   dia:  angular diameter in arcsec at 1 AU, 
  1397. X *   mag:  visual magnitude when 1 AU from sun and earth at 0 phase angle.
  1398. X *
  1399. X * all angles are in radians, all distances in AU.
  1400. X * the mean orbital elements are found by calling pelement(), then mutual
  1401. X *   perturbation corrections are applied as necessary.
  1402. X *
  1403. X * corrections for nutation and abberation must be made by the caller. The RA 
  1404. X *   and DEC calculated from the fully-corrected ecliptic coordinates are then
  1405. X *   the apparent geocentric coordinates. Further corrections can be made, if
  1406. X *   required, for atmospheric refraction and geocentric parallax although the
  1407. X *   intrinsic error herein of about 10 arcseconds is usually the dominant
  1408. X *   error at this stage.
  1409. X * TODO: combine the several intermediate expressions when get a good compiler.
  1410. X */
  1411. Xplans (mjd, p, lpd0, psi0, rp0, rho0, lam, bet, dia, mag)
  1412. Xdouble mjd;
  1413. Xint p;
  1414. Xdouble *lpd0, *psi0, *rp0, *rho0, *lam, *bet, *dia, *mag;
  1415. X{
  1416. X    static double plan[8][9];
  1417. X    static double lastmjd = -10000;
  1418. X    double dl;    /* perturbation correction for longitude */
  1419. X    double dr;    /*  "   orbital radius */
  1420. X    double dml;    /*  "   mean longitude */
  1421. X    double ds;    /*  "   eccentricity */
  1422. X    double dm;    /*  "   mean anomaly */
  1423. X    double da;    /*  "   semi-major axis */
  1424. X    double dhl;    /*  "   heliocentric longitude */
  1425. X    double lsn, rsn;/* true geocentric longitude of sun and sun-earth rad */
  1426. X    double mas;    /* mean anomaly of the sun */
  1427. X    double re;    /* radius of earth's orbit */
  1428. X    double lg;    /* longitude of earth */
  1429. X    double map[8];    /* array of mean anomalies for each planet */
  1430. X    double lpd, psi, rp, rho;
  1431. X    double ll, sll, cll;
  1432. X    double t;
  1433. X    double dt;
  1434. X    int pass;
  1435. X    int j;
  1436. X    double s, ma;
  1437. X    double nu, ea;
  1438. X    double lp, om;
  1439. X    double lo, slo, clo;
  1440. X    double inc, y;
  1441. X    double spsi, cpsi;
  1442. X    double rpd;
  1443. X
  1444. X    /* only need to fill in plan[] once for a given mjd */
  1445. X    if (mjd != lastmjd) {
  1446. X        pelement (mjd, plan);
  1447. X        lastmjd = mjd;
  1448. X    }
  1449. X
  1450. X    dt = 0;
  1451. X    t = mjd/36525.;
  1452. X    sunpos (mjd, &lsn, &rsn);
  1453. X    masun (mjd, &mas);
  1454. X        re = rsn;
  1455. X    lg = lsn+PI;
  1456. X
  1457. X    /* first find the true position of the planet at mjd.
  1458. X     * then repeat a second time for a slightly different time based
  1459. X     * on the position found in the first pass to account for light-travel
  1460. X     * time.
  1461. X     */
  1462. X    for (pass = 0; pass < 2; pass++) {
  1463. X
  1464. X        for (j = 0; j < 8; j++)
  1465. X        map[j] = degrad(plan[j][0]-plan[j][2]-dt*plan[j][1]);
  1466. X
  1467. X        /* set initial corrections to 0.
  1468. X         * then modify as necessary for the planet of interest.
  1469. X         */
  1470. X        dl = 0;
  1471. X        dr = 0;
  1472. X        dml = 0;
  1473. X        ds = 0;
  1474. X        dm = 0;
  1475. X        da = 0;
  1476. X        dhl = 0;
  1477. X
  1478. X        switch (p) {
  1479. X
  1480. X        case MERCURY:
  1481. X        p_mercury (map, &dl, &dr);
  1482. X        break;
  1483. X
  1484. X        case VENUS:
  1485. X        p_venus (t, mas, map, &dl, &dr, &dml, &dm);
  1486. X        break;
  1487. X
  1488. X        case MARS:
  1489. X        p_mars (mas, map, &dl, &dr, &dml, &dm);
  1490. X        break;
  1491. X
  1492. X        case JUPITER:
  1493. X        p_jupiter (t, plan[p][3], &dml, &ds, &dm, &da);
  1494. X        break;
  1495. X
  1496. X        case SATURN:
  1497. X        p_saturn (t, plan[p][3], &dml, &ds, &dm, &da, &dhl);
  1498. X        break;
  1499. X
  1500. X        case URANUS:
  1501. X        p_uranus (t, plan[p][3], &dl, &dr, &dml, &ds, &dm, &da, &dhl);
  1502. X        break;
  1503. X
  1504. X        case NEPTUNE:
  1505. X        p_neptune (t, plan[p][3], &dl, &dr, &dml, &ds, &dm, &da, &dhl);
  1506. X        break;
  1507. X
  1508. X        case PLUTO:
  1509. X        /* no perturbation theory for pluto */
  1510. X        break;
  1511. X        }
  1512. X
  1513. X        s = plan[p][3]+ds;
  1514. X        ma = map[p]+dm;
  1515. X        anomaly (ma, s, &nu, &ea);
  1516. X        rp = (plan[p][6]+da)*(1-s*s)/(1+s*cos(nu));
  1517. X        lp = raddeg(nu)+plan[p][2]+raddeg(dml-dm);
  1518. X        lp = degrad(lp);
  1519. X        om = degrad(plan[p][5]);
  1520. X        lo = lp-om;
  1521. X        slo = sin(lo);
  1522. X        clo = cos(lo);
  1523. X        inc = degrad(plan[p][4]);
  1524. X        rp = rp+dr;
  1525. X        spsi = slo*sin(inc);
  1526. X        y = slo*cos(inc);
  1527. X        psi = asin(spsi)+dhl;
  1528. X        spsi = sin(psi);
  1529. X        lpd = atan(y/clo)+om+degrad(dl);
  1530. X        if (clo<0) lpd += PI;
  1531. X        range (&lpd, TWOPI);
  1532. X        cpsi = cos(psi);
  1533. X        rpd = rp*cpsi;
  1534. X        ll = lpd-lg;
  1535. X        rho = sqrt(re*re+rp*rp-2*re*rp*cpsi*cos(ll));
  1536. X
  1537. X        /* when we view a planet we see it in the position it occupied
  1538. X         * dt days ago, where rho is the distance between it and earth,
  1539. X         * in AU. use this as the new time for the next pass.
  1540. X         */
  1541. X        dt = rho*5.775518e-3;
  1542. X
  1543. X        if (pass == 0) {
  1544. X        /* save heliocentric coordinates after first pass since, being
  1545. X         * true, they are NOT to be corrected for light-travel time.
  1546. X         */
  1547. X        *lpd0 = lpd;
  1548. X        range (lpd0, TWOPI);
  1549. X        *psi0 = psi;
  1550. X        *rp0 = rp;
  1551. X        *rho0 = rho;
  1552. X        }
  1553. X    }
  1554. X
  1555. X        sll = sin(ll);
  1556. X    cll = cos(ll);
  1557. X        if (p < MARS) 
  1558. X        *lam = atan(-1*rpd*sll/(re-rpd*cll))+lg+PI;
  1559. X    else
  1560. X        *lam = atan(re*sll/(rpd-re*cll))+lpd;
  1561. X    range (lam, TWOPI);
  1562. X        *bet = atan(rpd*spsi*sin(*lam-lpd)/(cpsi*re*sll));
  1563. X    *dia = plan[p][7];
  1564. X    *mag = plan[p][8];
  1565. X}
  1566. X
  1567. X/* set auxilliary variables used for jupiter, saturn, uranus, and neptune */
  1568. Xstatic
  1569. Xaux_jsun (t, x1, x2, x3, x4, x5, x6)
  1570. Xdouble t;
  1571. Xdouble *x1, *x2, *x3, *x4, *x5, *x6;
  1572. X{
  1573. X        *x1 = t/5+0.1;
  1574. X        *x2 = mod2PI(4.14473+5.29691e1*t);
  1575. X        *x3 = mod2PI(4.641118+2.132991e1*t);
  1576. X        *x4 = mod2PI(4.250177+7.478172*t);
  1577. X        *x5 = 5 * *x3 - 2 * *x2;
  1578. X    *x6 = 2 * *x2 - 6 * *x3 + 3 * *x4;
  1579. X}
  1580. X
  1581. X/* find the mean anomaly of the sun at mjd.
  1582. X * this is the same as that used in sun() but when it was converted to C it
  1583. X * was not known it would be required outside that routine.
  1584. X * TODO: add an argument to sun() to return mas and eliminate this routine.
  1585. X */
  1586. Xstatic
  1587. Xmasun (mjd, mas)
  1588. Xdouble mjd;
  1589. Xdouble *mas;
  1590. X{
  1591. X    double t, t2;
  1592. X    double a, b;
  1593. X
  1594. X    t = mjd/36525;
  1595. X    t2 = t*t;
  1596. X    a = 9.999736042e1*t;
  1597. X    b = 360.*(a-(long)a);
  1598. X    *mas = degrad (3.5847583e2-(1.5e-4+3.3e-6*t)*t2+b);
  1599. X}
  1600. X
  1601. X/* perturbations for mercury */
  1602. Xstatic
  1603. Xp_mercury (map, dl, dr)
  1604. Xdouble map[];
  1605. Xdouble *dl, *dr;
  1606. X{
  1607. X    *dl = 2.04e-3*cos(5*map[2-1]-2*map[1-1]+2.1328e-1)+
  1608. X         1.03e-3*cos(2*map[2-1]-map[1-1]-2.8046)+
  1609. X         9.1e-4*cos(2*map[3]-map[1-1]-6.4582e-1)+
  1610. X         7.8e-4*cos(5*map[2-1]-3*map[1-1]+1.7692e-1);
  1611. X
  1612. X    *dr = 7.525e-6*cos(2*map[3]-map[1-1]+9.25251e-1)+
  1613. X         6.802e-6*cos(5*map[2-1]-3*map[1-1]-4.53642)+
  1614. X         5.457e-6*cos(2*map[2-1]-2*map[1-1]-1.24246)+
  1615. X         3.569e-6*cos(5*map[2-1]-map[1-1]-1.35699);
  1616. X}
  1617. X
  1618. X/* ....venus */
  1619. Xstatic
  1620. Xp_venus (t, mas, map, dl, dr, dml, dm)
  1621. Xdouble t, mas, map[];
  1622. Xdouble *dl, *dr, *dml, *dm;
  1623. X{
  1624. X    *dml = degrad (7.7e-4*sin(4.1406+t*2.6227));
  1625. X    *dm = *dml;
  1626. X
  1627. X    *dl = 3.13e-3*cos(2*mas-2*map[2-1]-2.587)+
  1628. X         1.98e-3*cos(3*mas-3*map[2-1]+4.4768e-2)+
  1629. X         1.36e-3*cos(mas-map[2-1]-2.0788)+
  1630. X         9.6e-4*cos(3*mas-2*map[2-1]-2.3721)+
  1631. X         8.2e-4*cos(map[3]-map[2-1]-3.6318);
  1632. X
  1633. X    *dr = 2.2501e-5*cos(2*mas-2*map[2-1]-1.01592)+
  1634. X         1.9045e-5*cos(3*mas-3*map[2-1]+1.61577)+
  1635. X         6.887e-6*cos(map[3]-map[2-1]-2.06106)+
  1636. X         5.172e-6*cos(mas-map[2-1]-5.08065e-1)+
  1637. X         3.62e-6*cos(5*mas-4*map[2-1]-1.81877)+
  1638. X         3.283e-6*cos(4*mas-4*map[2-1]+1.10851)+
  1639. X         3.074e-6*cos(2*map[3]-2*map[2-1]-9.62846e-1);
  1640. X}
  1641. X
  1642. X/* ....mars */
  1643. Xstatic
  1644. Xp_mars (mas, map, dl, dr, dml, dm)
  1645. Xdouble mas, map[];
  1646. Xdouble *dl, *dr, *dml, *dm;
  1647. X{
  1648. X    double a;
  1649. X
  1650. X    a = 3*map[3]-8*map[2]+4*mas;
  1651. X    *dml = degrad (-1*(1.133e-2*sin(a)+9.33e-3*cos(a)));
  1652. X    *dm = *dml;
  1653. X
  1654. X    *dl = 7.05e-3*cos(map[3]-map[2]-8.5448e-1)+
  1655. X         6.07e-3*cos(2*map[3]-map[2]-3.2873)+
  1656. X         4.45e-3*cos(2*map[3]-2*map[2]-3.3492)+
  1657. X         3.88e-3*cos(mas-2*map[2]+3.5771e-1)+
  1658. X         2.38e-3*cos(mas-map[2]+6.1256e-1)+
  1659. X         2.04e-3*cos(2*mas-3*map[2]+2.7688)+
  1660. X         1.77e-3*cos(3*map[2]-map[2-1]-1.0053)+
  1661. X         1.36e-3*cos(2*mas-4*map[2]+2.6894)+
  1662. X         1.04e-3*cos(map[3]+3.0749e-1);
  1663. X
  1664. X    *dr = 5.3227e-5*cos(map[3]-map[2]+7.17864e-1)+
  1665. X         5.0989e-5*cos(2*map[3]-2*map[2]-1.77997)+
  1666. X         3.8278e-5*cos(2*map[3]-map[2]-1.71617)+
  1667. X         1.5996e-5*cos(mas-map[2]-9.69618e-1)+
  1668. X         1.4764e-5*cos(2*mas-3*map[2]+1.19768)+
  1669. X         8.966e-6*cos(map[3]-2*map[2]+7.61225e-1);
  1670. X     *dr += 7.914e-6*cos(3*map[3]-2*map[2]-2.43887)+
  1671. X         7.004e-6*cos(2*map[3]-3*map[2]-1.79573)+
  1672. X         6.62e-6*cos(mas-2*map[2]+1.97575)+
  1673. X         4.93e-6*cos(3*map[3]-3*map[2]-1.33069)+
  1674. X         4.693e-6*cos(3*mas-5*map[2]+3.32665)+
  1675. X         4.571e-6*cos(2*mas-4*map[2]+4.27086)+
  1676. X         4.409e-6*cos(3*map[3]-map[2]-2.02158);
  1677. X}
  1678. X
  1679. X/* ....jupiter */
  1680. Xstatic
  1681. Xp_jupiter (t, s, dml, ds, dm, da)
  1682. Xdouble t, s;
  1683. Xdouble *dml, *ds, *dm, *da;
  1684. X{
  1685. X    double dp;
  1686. X    double x1, x2, x3, x4, x5, x6, x7;
  1687. X    double sx3, cx3, s2x3, c2x3;
  1688. X        double sx5, cx5, s2x5;
  1689. X    double sx6;
  1690. X        double sx7, cx7, s2x7, c2x7, s3x7, c3x7, s4x7, c4x7, c5x7;
  1691. X
  1692. X    aux_jsun (t, &x1, &x2, &x3, &x4, &x5, &x6);
  1693. X        x7 = x3-x2;
  1694. X    sx3 = sin(x3);
  1695. X    cx3 = cos(x3);
  1696. X        s2x3 = sin(2*x3);
  1697. X    c2x3 = cos(2*x3);
  1698. X        sx5 = sin(x5);
  1699. X    cx5 = cos(x5);
  1700. X        s2x5 = sin(2*x5);
  1701. X    sx6 = sin(x6);
  1702. X        sx7 = sin(x7);
  1703. X    cx7 = cos(x7);
  1704. X        s2x7 = sin(2*x7);
  1705. X    c2x7 = cos(2*x7);
  1706. X        s3x7 = sin(3*x7);
  1707. X    c3x7 = cos(3*x7);
  1708. X        s4x7 = sin(4*x7);
  1709. X    c4x7 = cos(4*x7);
  1710. X        c5x7 = cos(5*x7);
  1711. X
  1712. X    *dml = (3.31364e-1-(1.0281e-2+4.692e-3*x1)*x1)*sx5+
  1713. X          (3.228e-3-(6.4436e-2-2.075e-3*x1)*x1)*cx5-
  1714. X          (3.083e-3+(2.75e-4-4.89e-4*x1)*x1)*s2x5+
  1715. X          2.472e-3*sx6+1.3619e-2*sx7+1.8472e-2*s2x7+6.717e-3*s3x7+
  1716. X          2.775e-3*s4x7+6.417e-3*s2x7*sx3+
  1717. X          (7.275e-3-1.253e-3*x1)*sx7*sx3+
  1718. X          2.439e-3*s3x7*sx3-(3.5681e-2+1.208e-3*x1)*sx7*cx3;
  1719. X        *dml += -3.767e-3*c2x7*sx3-(3.3839e-2+1.125e-3*x1)*cx7*sx3-
  1720. X          4.261e-3*s2x7*cx3+
  1721. X          (1.161e-3*x1-6.333e-3)*cx7*cx3+
  1722. X          2.178e-3*cx3-6.675e-3*c2x7*cx3-2.664e-3*c3x7*cx3-
  1723. X          2.572e-3*sx7*s2x3-3.567e-3*s2x7*s2x3+2.094e-3*cx7*c2x3+
  1724. X          3.342e-3*c2x7*c2x3;
  1725. X    *dml = degrad(*dml);
  1726. X
  1727. X    *ds = (3606+(130-43*x1)*x1)*sx5+(1289-580*x1)*cx5-6764*sx7*sx3-
  1728. X         1110*s2x7*sx3-224*s3x7*sx3-204*sx3+(1284+116*x1)*cx7*sx3+
  1729. X         188*c2x7*sx3+(1460+130*x1)*sx7*cx3+224*s2x7*cx3-817*cx3+
  1730. X         6074*cx3*cx7+992*c2x7*cx3+
  1731. X         508*c3x7*cx3+230*c4x7*cx3+108*c5x7*cx3;
  1732. X    *ds += -(956+73*x1)*sx7*s2x3+448*s2x7*s2x3+137*s3x7*s2x3+
  1733. X         (108*x1-997)*cx7*s2x3+480*c2x7*s2x3+148*c3x7*s2x3+
  1734. X         (99*x1-956)*sx7*c2x3+490*s2x7*c2x3+
  1735. X         158*s3x7*c2x3+179*c2x3+(1024+75*x1)*cx7*c2x3-
  1736. X         437*c2x7*c2x3-132*c3x7*c2x3;
  1737. X    *ds *= 1e-7;
  1738. X
  1739. X    dp = (7.192e-3-3.147e-3*x1)*sx5-4.344e-3*sx3+
  1740. X         (x1*(1.97e-4*x1-6.75e-4)-2.0428e-2)*cx5+
  1741. X         3.4036e-2*cx7*sx3+(7.269e-3+6.72e-4*x1)*sx7*sx3+
  1742. X         5.614e-3*c2x7*sx3+2.964e-3*c3x7*sx3+3.7761e-2*sx7*cx3+
  1743. X         6.158e-3*s2x7*cx3-
  1744. X         6.603e-3*cx7*cx3-5.356e-3*sx7*s2x3+2.722e-3*s2x7*s2x3+
  1745. X         4.483e-3*cx7*s2x3-2.642e-3*c2x7*s2x3+4.403e-3*sx7*c2x3-
  1746. X         2.536e-3*s2x7*c2x3+5.547e-3*cx7*c2x3-2.689e-3*c2x7*c2x3;
  1747. X
  1748. X    *dm = *dml-(degrad(dp)/s);
  1749. X
  1750. X    *da = 205*cx7-263*cx5+693*c2x7+312*c3x7+147*c4x7+299*sx7*sx3+
  1751. X         181*c2x7*sx3+204*s2x7*cx3+111*s3x7*cx3-337*cx7*cx3-
  1752. X         111*c2x7*cx3;
  1753. X    *da *= 1e-6;
  1754. X}
  1755. X
  1756. X/* ....saturn */
  1757. Xstatic
  1758. Xp_saturn (t, s, dml, ds, dm, da, dhl)
  1759. Xdouble t, s;
  1760. Xdouble *dml, *ds, *dm, *da, *dhl;
  1761. X{
  1762. X    double dp;
  1763. X    double x1, x2, x3, x4, x5, x6, x7, x8;
  1764. X    double sx3, cx3, s2x3, c2x3, s3x3, c3x3, s4x3, c4x3;
  1765. X        double sx5, cx5, s2x5, c2x5;
  1766. X    double sx6;
  1767. X        double sx7, cx7, s2x7, c2x7, s3x7, c3x7, s4x7, c4x7, c5x7, s5x7;
  1768. X    double s2x8, c2x8, s3x8, c3x8;
  1769. X
  1770. X    aux_jsun (t, &x1, &x2, &x3, &x4, &x5, &x6);
  1771. X        x7 = x3-x2;
  1772. X    sx3 = sin(x3);
  1773. X    cx3 = cos(x3);
  1774. X        s2x3 = sin(2*x3);
  1775. X    c2x3 = cos(2*x3);
  1776. X        sx5 = sin(x5);
  1777. X    cx5 = cos(x5);
  1778. X        s2x5 = sin(2*x5);
  1779. X    sx6 = sin(x6);
  1780. X        sx7 = sin(x7);
  1781. X    cx7 = cos(x7);
  1782. X        s2x7 = sin(2*x7);
  1783. X    c2x7 = cos(2*x7);
  1784. X        s3x7 = sin(3*x7);
  1785. X    c3x7 = cos(3*x7);
  1786. X        s4x7 = sin(4*x7);
  1787. X    c4x7 = cos(4*x7);
  1788. X        c5x7 = cos(5*x7);
  1789. X
  1790. X    s3x3 = sin(3*x3);
  1791. X    c3x3 = cos(3*x3);
  1792. X    s4x3 = sin(4*x3);
  1793. X    c4x3 = cos(4*x3);
  1794. X    c2x5 = cos(2*x5);
  1795. X    s5x7 = sin(5*x7);
  1796. X    x8 = x4-x3;
  1797. X    s2x8 = sin(2*x8);
  1798. X    c2x8 = cos(2*x8);
  1799. X    s3x8 = sin(3*x8);
  1800. X    c3x8 = cos(3*x8);
  1801. X
  1802. X    *dml = 7.581e-3*s2x5-7.986e-3*sx6-1.48811e-1*sx7-4.0786e-2*s2x7-
  1803. X          (8.14181e-1-(1.815e-2-1.6714e-2*x1)*x1)*sx5-
  1804. X          (1.0497e-2-(1.60906e-1-4.1e-3*x1)*x1)*cx5-1.5208e-2*s3x7-
  1805. X          6.339e-3*s4x7-6.244e-3*sx3-1.65e-2*s2x7*sx3+
  1806. X          (8.931e-3+2.728e-3*x1)*sx7*sx3-5.775e-3*s3x7*sx3+
  1807. X          (8.1344e-2+3.206e-3*x1)*cx7*sx3+1.5019e-2*c2x7*sx3;
  1808. X    *dml += (8.5581e-2+2.494e-3*x1)*sx7*cx3+1.4394e-2*c2x7*cx3+
  1809. X          (2.5328e-2-3.117e-3*x1)*cx7*cx3+
  1810. X          6.319e-3*c3x7*cx3+6.369e-3*sx7*s2x3+9.156e-3*s2x7*s2x3+
  1811. X          7.525e-3*s3x8*s2x3-5.236e-3*cx7*c2x3-7.736e-3*c2x7*c2x3-
  1812. X          7.528e-3*c3x8*c2x3;
  1813. X    *dml = degrad(*dml);
  1814. X
  1815. X    *ds = (-7927+(2548+91*x1)*x1)*sx5+(13381+(1226-253*x1)*x1)*cx5+
  1816. X         (248-121*x1)*s2x5-(305+91*x1)*c2x5+412*s2x7+12415*sx3+
  1817. X         (390-617*x1)*sx7*sx3+(165-204*x1)*s2x7*sx3+26599*cx7*sx3-
  1818. X         4687*c2x7*sx3-1870*c3x7*sx3-821*c4x7*sx3-
  1819. X         377*c5x7*sx3+497*c2x8*sx3+(163-611*x1)*cx3;
  1820. X    *ds += -12696*sx7*cx3-4200*s2x7*cx3-1503*s3x7*cx3-619*s4x7*cx3-
  1821. X         268*s5x7*cx3-(282+1306*x1)*cx7*cx3+(-86+230*x1)*c2x7*cx3+
  1822. X         461*s2x8*cx3-350*s2x3+(2211-286*x1)*sx7*s2x3-
  1823. X         2208*s2x7*s2x3-568*s3x7*s2x3-346*s4x7*s2x3-
  1824. X         (2780+222*x1)*cx7*s2x3+(2022+263*x1)*c2x7*s2x3+248*c3x7*s2x3+
  1825. X         242*s3x8*s2x3+467*c3x8*s2x3-490*c2x3-(2842+279*x1)*sx7*c2x3;
  1826. X    *ds += (128+226*x1)*s2x7*c2x3+224*s3x7*c2x3+
  1827. X         (-1594+282*x1)*cx7*c2x3+(2162-207*x1)*c2x7*c2x3+
  1828. X         561*c3x7*c2x3+343*c4x7*c2x3+469*s3x8*c2x3-242*c3x8*c2x3-
  1829. X         205*sx7*s3x3+262*s3x7*s3x3+208*cx7*c3x3-271*c3x7*c3x3-
  1830. X         382*c3x7*s4x3-376*s3x7*c4x3;
  1831. X    *ds *= 1e-7;
  1832. X
  1833. X    dp = (7.7108e-2+(7.186e-3-1.533e-3*x1)*x1)*sx5-7.075e-3*sx7+
  1834. X         (4.5803e-2-(1.4766e-2+5.36e-4*x1)*x1)*cx5-7.2586e-2*cx3-
  1835. X         7.5825e-2*sx7*sx3-2.4839e-2*s2x7*sx3-8.631e-3*s3x7*sx3-
  1836. X         1.50383e-1*cx7*cx3+2.6897e-2*c2x7*cx3+1.0053e-2*c3x7*cx3-
  1837. X         (1.3597e-2+1.719e-3*x1)*sx7*s2x3+1.1981e-2*s2x7*c2x3;
  1838. X    dp += -(7.742e-3-1.517e-3*x1)*cx7*s2x3+
  1839. X         (1.3586e-2-1.375e-3*x1)*c2x7*c2x3-
  1840. X         (1.3667e-2-1.239e-3*x1)*sx7*c2x3+
  1841. X         (1.4861e-2+1.136e-3*x1)*cx7*c2x3-
  1842. X         (1.3064e-2+1.628e-3*x1)*c2x7*c2x3;
  1843. X
  1844. X    *dm = *dml-(degrad(dp)/s);
  1845. X
  1846. X    *da = 572*sx5-1590*s2x7*cx3+2933*cx5-647*s3x7*cx3+33629*cx7-
  1847. X         344*s4x7*cx3-3081*c2x7+2885*cx7*cx3-1423*c3x7+
  1848. X         (2172+102*x1)*c2x7*cx3-671*c4x7+296*c3x7*cx3-320*c5x7-
  1849. X         267*s2x7*s2x3+1098*sx3-778*cx7*s2x3-2812*sx7*sx3;
  1850. X    *da += 495*c2x7*s2x3+688*s2x7*sx3+250*c3x7*s2x3-393*s3x7*sx3-
  1851. X         856*sx7*c2x3-228*s4x7*sx3+441*s2x7*c2x3+2138*cx7*sx3+
  1852. X         296*c2x7*c2x3-999*c2x7*sx3+211*c3x7*c2x3-642*c3x7*sx3-
  1853. X         427*sx7*s3x3-325*c4x7*sx3+398*s3x7*s3x3-890*cx3+
  1854. X         344*cx7*c3x3+2206*sx7*cx3-427*c3x7*c3x3;
  1855. X    *da *= 1e-6;
  1856. X
  1857. X    *dhl = 7.47e-4*cx7*sx3+1.069e-3*cx7*cx3+2.108e-3*s2x7*s2x3+
  1858. X          1.261e-3*c2x7*s2x3+1.236e-3*s2x7*c2x3-2.075e-3*c2x7*c2x3;
  1859. X    *dhl = degrad(*dhl);
  1860. X}
  1861. X
  1862. X/* ....uranus */
  1863. Xstatic
  1864. Xp_uranus (t, s, dl, dr, dml, ds, dm, da, dhl)
  1865. Xdouble t, s;
  1866. Xdouble *dl, *dr, *dml, *ds, *dm, *da, *dhl;
  1867. X{
  1868. X    double dp;
  1869. X    double x1, x2, x3, x4, x5, x6;
  1870. X    double x8, x9, x10, x11, x12;
  1871. X    double sx4, cx4, s2x4, c2x4;
  1872. X    double sx9, cx9, s2x9, c2x9;
  1873. X    double sx11, cx11;
  1874. X
  1875. X    aux_jsun (t, &x1, &x2, &x3, &x4, &x5, &x6);
  1876. X
  1877. X        x8 = mod2PI(1.46205+3.81337*t);
  1878. X        x9 = 2*x8-x4;
  1879. X    sx9 = sin(x9);
  1880. X    cx9 = cos(x9);
  1881. X        s2x9 = sin(2*x9);
  1882. X    c2x9 = cos(2*x9);
  1883. X
  1884. X    x10 = x4-x2;
  1885. X    x11 = x4-x3;
  1886. X    x12 = x8-x4;
  1887. X
  1888. X    *dml = (8.64319e-1-1.583e-3*x1)*sx9+(8.2222e-2-6.833e-3*x1)*cx9+
  1889. X          3.6017e-2*s2x9-3.019e-3*c2x9+8.122e-3*sin(x6);
  1890. X    *dml = degrad(*dml);
  1891. X
  1892. X    dp = 1.20303e-1*sx9+6.197e-3*s2x9+(1.9472e-2-9.47e-4*x1)*cx9;
  1893. X    *dm = *dml-(degrad(dp)/s);
  1894. X
  1895. X    *ds = (163*x1-3349)*sx9+20981*cx9+1311*c2x9;
  1896. X    *ds *= 1e-7;
  1897. X
  1898. X    *da = -3.825e-3*cx9;
  1899. X
  1900. X    *dl = (1.0122e-2-9.88e-4*x1)*sin(x4+x11)+
  1901. X         (-3.8581e-2+(2.031e-3-1.91e-3*x1)*x1)*cos(x4+x11)+
  1902. X         (3.4964e-2-(1.038e-3-8.68e-4*x1)*x1)*cos(2*x4+x11)+
  1903. X         5.594e-3*sin(x4+3*x12)-1.4808e-2*sin(x10)-
  1904. X         5.794e-3*sin(x11)+2.347e-3*cos(x11)+9.872e-3*sin(x12)+
  1905. X         8.803e-3*sin(2*x12)-4.308e-3*sin(3*x12);
  1906. X
  1907. X    sx11 = sin(x11);
  1908. X    cx11 = cos(x11);
  1909. X    sx4 = sin(x4);
  1910. X    cx4 = cos(x4);
  1911. X    s2x4 = sin(2*x4);
  1912. X    c2x4 = cos(2*x4);
  1913. X    *dhl = (4.58e-4*sx11-6.42e-4*cx11-5.17e-4*cos(4*x12))*sx4-
  1914. X          (3.47e-4*sx11+8.53e-4*cx11+5.17e-4*sin(4*x11))*cx4+
  1915. X          4.03e-4*(cos(2*x12)*s2x4+sin(2*x12)*c2x4);
  1916. X    *dhl = degrad(*dhl);
  1917. X
  1918. X    *dr = -25948+4985*cos(x10)-1230*cx4+3354*cos(x11)+904*cos(2*x12)+
  1919. X         894*(cos(x12)-cos(3*x12))+(5795*cx4-1165*sx4+1388*c2x4)*sx11+
  1920. X         (1351*cx4+5702*sx4+1388*s2x4)*cos(x11);
  1921. X    *dr *= 1e-6;
  1922. X}
  1923. X
  1924. X/* ....neptune */
  1925. Xstatic
  1926. Xp_neptune (t, s, dl, dr, dml, ds, dm, da, dhl)
  1927. Xdouble t, s;
  1928. Xdouble *dl, *dr, *dml, *ds, *dm, *da, *dhl;
  1929. X{
  1930. X    double dp;
  1931. X    double x1, x2, x3, x4, x5, x6;
  1932. X    double x8, x9, x10, x11, x12;
  1933. X    double sx8, cx8;
  1934. X    double sx9, cx9, s2x9, c2x9;
  1935. X    double s2x12, c2x12;
  1936. X
  1937. X    aux_jsun (t, &x1, &x2, &x3, &x4, &x5, &x6);
  1938. X
  1939. X        x8 = mod2PI(1.46205+3.81337*t);
  1940. X        x9 = 2*x8-x4;
  1941. X    sx9 = sin(x9);
  1942. X    cx9 = cos(x9);
  1943. X        s2x9 = sin(2*x9);
  1944. X    c2x9 = cos(2*x9);
  1945. X
  1946. X    x10 = x8-x2;
  1947. X    x11 = x8-x3;
  1948. X    x12 = x8-x4;
  1949. X
  1950. X    *dml = (1.089e-3*x1-5.89833e-1)*sx9+(4.658e-3*x1-5.6094e-2)*cx9-
  1951. X          2.4286e-2*s2x9;
  1952. X    *dml = degrad(*dml);
  1953. X
  1954. X    dp = 2.4039e-2*sx9-2.5303e-2*cx9+6.206e-3*s2x9-5.992e-3*c2x9;
  1955. X
  1956. X    *dm = *dml-(degrad(dp)/s);
  1957. X
  1958. X    *ds = 4389*sx9+1129*s2x9+4262*cx9+1089*c2x9;
  1959. X    *ds *= 1e-7;
  1960. X
  1961. X    *da = 8189*cx9-817*sx9+781*c2x9;
  1962. X    *da *= 1e-6;
  1963. X
  1964. X    s2x12 = sin(2*x12);
  1965. X    c2x12 = cos(2*x12);
  1966. X    sx8 = sin(x8);
  1967. X    cx8 = cos(x8);
  1968. X    *dl = -9.556e-3*sin(x10)-5.178e-3*sin(x11)+2.572e-3*s2x12-
  1969. X         2.972e-3*c2x12*sx8-2.833e-3*s2x12*cx8;
  1970. X
  1971. X    *dhl = 3.36e-4*c2x12*sx8+3.64e-4*s2x12*cx8;
  1972. X    *dhl = degrad(*dhl);
  1973. X
  1974. X    *dr = -40596+4992*cos(x10)+2744*cos(x11)+2044*cos(x12)+1051*c2x12;
  1975. X    *dr *= 1e-6;
  1976. X}
  1977. X
  1978. END_OF_FILE
  1979.   if test 17647 -ne `wc -c <'plans.c'`; then
  1980.     echo shar: \"'plans.c'\" unpacked with wrong size!
  1981.   fi
  1982.   # end of 'plans.c'
  1983. fi
  1984. echo shar: End of archive 5 \(of 9\).
  1985. cp /dev/null ark5isdone
  1986. MISSING=""
  1987. for I in 1 2 3 4 5 6 7 8 9 ; do
  1988.     if test ! -f ark${I}isdone ; then
  1989.     MISSING="${MISSING} ${I}"
  1990.     fi
  1991. done
  1992. if test "${MISSING}" = "" ; then
  1993.     echo You have unpacked all 9 archives.
  1994.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1995. else
  1996.     echo You still must unpack the following archives:
  1997.     echo "        " ${MISSING}
  1998. fi
  1999. exit 0
  2000. exit 0 # Just in case...
  2001.