home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume19 / xephem / part21 < prev    next >
Encoding:
Text File  |  1993-05-15  |  57.9 KB  |  1,918 lines

  1. Newsgroups: comp.sources.x
  2. From: ecdowney@pobox.cca.cr.rockwell.com (Elwood Downey)
  3. Subject: v19i109:  xephem - astronomical ephemeris program, Part21/21
  4. Message-ID: <1993May10.221458.9906@sparky.imd.sterling.com>
  5. X-Md4-Signature: c2ebeab684497b5418ce2dfbd923d04e
  6. Date: Mon, 10 May 1993 22:14:58 GMT
  7. Approved: chris@sparky.imd.sterling.com
  8.  
  9. Submitted-by: ecdowney@pobox.cca.cr.rockwell.com (Elwood Downey)
  10. Posting-number: Volume 19, Issue 109
  11. Archive-name: xephem/part21
  12. Environment: X11r4, OSF/Motif
  13. Supersedes: xephem: Volume 16, Issue 112-134
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then feed it
  17. # into a shell via "sh file" or similar.  To overwrite existing files,
  18. # type "sh file -c".
  19. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  20. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  21. # Contents:  Imakefile Makefile.simple Manifest aa_hadec.c astro.h
  22. #   eq_ecl.c marsmap.c moon.c moonnf.c msgmenu.c nutation.c obliq.c
  23. #   patchlevel.h pelement.c reduce.c refract.c riset.c sun.c utc_gst.c
  24. # Wrapped by chris@nova on Mon May 10 16:41:55 1993
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. echo If this archive is complete, you will see the following message:
  27. echo '          "shar: End of archive 21 (of 21)."'
  28. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'Imakefile'\"
  30. else
  31.   echo shar: Extracting \"'Imakefile'\" \(1456 characters\)
  32.   sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  33. XSRCS =    aa_hadec.c anomaly.c cal_mjd.c calmenu.c circum.c comet.c compiler.c \
  34. X    constel.c datamenu.c db.c dbmenu.c earthmap.c earthmenu.c eq_ecl.c \
  35. X    formats.c helpmenu.c jupmenu.c listmenu.c mainmenu.c marsmap.c \
  36. X    marsmenu.c misc.c moon.c moonmenu.c moonnf.c msgmenu.c nutation.c \
  37. X    objmenu.c obliq.c parallax.c pelement.c plans.c plot_aux.c plotmenu.c \
  38. X    precess.c preferences.c query.c reduce.c refract.c riset.c \
  39. X    riset_cir.c satmenu.c sex_dec.c skyfiltmenu.c skyviewmenu.c \
  40. X    solsysmenu.c srchmenu.c sun.c time.c utc_gst.c versionmenu.c xephem.c
  41. X
  42. XOBJS =    aa_hadec.o anomaly.o cal_mjd.o calmenu.o circum.o comet.o compiler.o \
  43. X    constel.o datamenu.o db.o dbmenu.o earthmap.o earthmenu.o eq_ecl.o \
  44. X    formats.o helpmenu.o jupmenu.o listmenu.o mainmenu.o marsmap.o \
  45. X    marsmenu.o misc.o moon.o moonmenu.o moonnf.o msgmenu.o nutation.o \
  46. X    objmenu.o obliq.o parallax.o pelement.o plans.o plot_aux.o plotmenu.o \
  47. X    precess.o preferences.o query.o reduce.o refract.o riset.o \
  48. X    riset_cir.o satmenu.o sex_dec.o skyfiltmenu.o skyviewmenu.o \
  49. X    solsysmenu.o srchmenu.o sun.o time.o utc_gst.o versionmenu.o xephem.o
  50. X
  51. X       DEPXMLIB = $(USRLIBDIR)/libXm.a
  52. X          XMLIB = -lXm
  53. XLOCAL_LIBRARIES = $(XMLIB) $(XTOOLLIB) $(XLIB)
  54. X        DEPLIBS = $(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXLIB)
  55. X  SYS_LIBRARIES = -lm
  56. X       PROGRAMS = xephem
  57. X
  58. XComplexProgramTarget(xephem)
  59. X
  60. X# especially worth having this dependency so the displayed version is current.
  61. Xversionmenu.o:    patchlevel.h
  62. END_OF_FILE
  63.   if test 1456 -ne `wc -c <'Imakefile'`; then
  64.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  65.   fi
  66.   # end of 'Imakefile'
  67. fi
  68. if test -f 'Makefile.simple' -a "${1}" != "-c" ; then 
  69.   echo shar: Will not clobber existing file \"'Makefile.simple'\"
  70. else
  71.   echo shar: Extracting \"'Makefile.simple'\" \(1493 characters\)
  72.   sed "s/^X//" >'Makefile.simple' <<'END_OF_FILE'
  73. X# Simple Makefile for xephem v2.4b.
  74. X# We include sample compile and link flags for a few popular systems.
  75. X
  76. X# "stock" X systems
  77. XCLDFLAGS = 
  78. XCFLAGS = $(CLDFLAGS) -O -D_NO_PROTO
  79. XLDFLAGS = $(CLDFLAGS)
  80. XLIBS = -lXm -lXt -lX11 -lm
  81. X
  82. X# SVR4
  83. X# CLDFLAGS = 
  84. X# CFLAGS = $(CLDFLAGS) -O
  85. X# LDFLAGS = $(CLDFLAGS)
  86. X# LIBS = -lXm -lXt -lX11 -lsocket -lnsl -lc -lm /usr/ucblib/libucb.a
  87. X
  88. X# SVR3.2 with Metrolink X
  89. X# CLDFLAGS = 
  90. X# CFLAGS = $(CLDFLAGS) -D_NO_PROTO -DSYSV -O
  91. X# LDFLAGS = $(CLDFLAGS) -L/usr/lib/X11/libs
  92. X# LIBS = -lXm -lXt -lX11 -lm -lpt -lsocket -lnet -lnsl_s -lc -lgnu -lPW
  93. X
  94. X# try the following CFLAGS and LIBS if set WANT_EDITRES in xephem.c
  95. X# CLDFLAGS = 
  96. X# CFLAGS = $(CLDFLAGS) -DWANT_EDITRES -O
  97. X# LDFLAGS = $(CLDFLAGS)
  98. X# LIBS= -lXm -lXt -lXmu -lXext -lX11 -lm
  99. X
  100. XOBJS =    aa_hadec.o anomaly.o cal_mjd.o calmenu.o circum.o comet.o compiler.o \
  101. X    constel.o datamenu.o db.o dbmenu.o earthmap.o earthmenu.o eq_ecl.o \
  102. X    formats.o helpmenu.o jupmenu.o listmenu.o mainmenu.o marsmap.o \
  103. X    marsmenu.o misc.o moon.o moonmenu.o moonnf.o msgmenu.o nutation.o \
  104. X    objmenu.o obliq.o parallax.o pelement.o plans.o plot_aux.o plotmenu.o \
  105. X    precess.o preferences.o query.o reduce.o refract.o riset.o \
  106. X    riset_cir.o satmenu.o sex_dec.o skyfiltmenu.o skyviewmenu.o \
  107. X    solsysmenu.o srchmenu.o sun.o time.o utc_gst.o versionmenu.o xephem.o
  108. X
  109. X.PRECIOUS:    xephem
  110. X
  111. Xxephem: $(OBJS)
  112. X    $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
  113. X
  114. X# especially worth having this dependency so the displayed version is current.
  115. Xversionmenu.o:    patchlevel.h
  116. END_OF_FILE
  117.   if test 1493 -ne `wc -c <'Makefile.simple'`; then
  118.     echo shar: \"'Makefile.simple'\" unpacked with wrong size!
  119.   fi
  120.   # end of 'Makefile.simple'
  121. fi
  122. if test -f 'Manifest' -a "${1}" != "-c" ; then 
  123.   echo shar: Will not clobber existing file \"'Manifest'\"
  124. else
  125.   echo shar: Extracting \"'Manifest'\" \(3608 characters\)
  126.   sed "s/^X//" >'Manifest' <<'END_OF_FILE'
  127. XCopyright    notice of ownership, permissions and limitations
  128. XImakefile    sample Imakefile for xmkmf
  129. XMakefile.simple    simple sample make file.
  130. XManifest    this file.
  131. XREADME        check here for hints before building.
  132. XXEphem.ad    defaults file (basically the same as fallback ones in xephem.c)
  133. Xephem.db    sample database file.
  134. Xephem.plt    sample plot file (an analemma)
  135. Xxephem.hlp    help text file.
  136. Xxephem.man    manual page, written with the nroff -man macros.
  137. X
  138. Xaa_hadec.c      convert between alt/az and hour angle/dec.
  139. Xanomaly.c       compute anomaly.
  140. Xastro.h         unit conversion macros and planet defines.
  141. Xcal_mjd.c       converters to and from modified julian date.
  142. Xcalmenu.c    control the calendar on the main menu.
  143. Xcircum.c        main "astronomy" entry point that finds where anything is.
  144. Xcircum.h        defines Now and Sky structures.
  145. Xcomet.c         compute comet position from elements.
  146. Xcompiler.c      compile and execute general expressions with screen fields.
  147. Xconstel.c       handles determing and printing constellation info.
  148. Xdatamenu.c    manage the general data menu.
  149. Xdb.c        read and process the database files, and maintain in-memory db.
  150. Xdbmenu.c    manage the database menu.
  151. Xearthmap.c    coordinates for the simple earth map.
  152. Xearthmenu.c    manage the sunlit earth menu.
  153. Xeq_ecl.c        convert between equitorial and eclipitic coords.
  154. Xformats.c       basic date, time, prompts, etc formats.
  155. Xhelpmenu.c    manage the help menu and supporting text file.
  156. Xjupmenu.c    manage the jupiter moon map menu.
  157. Xlistmenu.c    manage the listing control menu.
  158. Xmainmenu.c    manage the main menu.
  159. Xmap.h        typedefs useful for maps consisting of sets of lines.
  160. Xmarsmap.c    coordincates for the simple mars map.
  161. Xmarsmenu.c    manage the mars central meridian longitude menu.
  162. Xmisc.c        everyone needs one of these!
  163. Xmoon.c          compute moon position.
  164. Xmoonmenu.c    manage the moon display menu.
  165. Xmoonnf.c        compute new and full moon dates.
  166. Xmsgmenu.c    manage the message alert mechanism.
  167. Xnutation.c      compute nutation correction.
  168. Xobjmenu.c    manage the objx/y menu.
  169. Xobliq.c         compute obliquity.
  170. Xparallax.c      functions to compute earth rim parallax correction.
  171. Xpatchlevel.h    defines PATCHLEVEL which establishes the official release level.
  172. Xpelement.c      basic planet position polynomial coefficients.
  173. Xplans.c         use polynomials to find planet location at any certain time.
  174. Xplot_aux.c    manage the actual plotting menu and read supporting files.
  175. Xplotmenu.c    manage the plot control menu and write supporting files.
  176. Xprecess.c       compute precession correction.
  177. Xpreferences.c    code to maintain the setting of the user preference settings.
  178. Xpreferences.h    header file for use by modules setting or getting preferences.
  179. Xquery.c        general purpose menu query tool.
  180. Xreduce.c        convert elliptical elements from one epoch to another.
  181. Xrefract.c       atmospheric refraction model.
  182. Xriset.c         find basic rise/set sideral times of a fixed object.
  183. Xriset_cir.c     iteratively solve for local rise/set times of moving objects.
  184. Xsatmenu.c    manage the Saturn menu.
  185. Xsex_dec.c       convert between sexagesimal and decimal notation.
  186. Xskyfiltmenu.c    manage the sky view type filter menu.
  187. Xskyviewmenu.c    manage the circular sky view menu.
  188. Xsmallfm.xbm    small moon bitmap.
  189. Xsolsysmenu.c    manage the solar system menu.
  190. Xsrchmenu.c    manage the search control menu.
  191. Xsun.c           compute location of sun at any time.
  192. Xtime.c          manage setting and getting the time from the os
  193. Xutc_gst.c       convert between UT1 and Greenwich sidereal time
  194. Xversionmenu.c   current version notice, and revision history comments.
  195. Xxephem.c    main() and misc minor support utility functions.
  196. END_OF_FILE
  197.   if test 3608 -ne `wc -c <'Manifest'`; then
  198.     echo shar: \"'Manifest'\" unpacked with wrong size!
  199.   fi
  200.   # end of 'Manifest'
  201. fi
  202. if test -f 'aa_hadec.c' -a "${1}" != "-c" ; then 
  203.   echo shar: Will not clobber existing file \"'aa_hadec.c'\"
  204. else
  205.   echo shar: Extracting \"'aa_hadec.c'\" \(2283 characters\)
  206.   sed "s/^X//" >'aa_hadec.c' <<'END_OF_FILE'
  207. X#include <stdio.h>
  208. X#include <math.h>
  209. X#include "astro.h"
  210. X
  211. X#if defined(__STDC__) || defined(__cplusplus)
  212. X#define P_(s) s
  213. X#else
  214. X#define P_(s) ()
  215. X#endif
  216. X
  217. Xvoid aa_hadec P_((double lat, double alt, double az, double *ha, double *dec));
  218. Xvoid hadec_aa P_((double lat, double ha, double dec, double *alt, double *az));
  219. Xstatic void aaha_aux P_((double lat, double x, double y, double *p, double *q));
  220. X
  221. X#undef P_
  222. X
  223. X/* given latitude (n+, radians), lat, altitude (up+, radians), alt, and
  224. X * azimuth (angle round to the east from north+, radians),
  225. X * return hour angle (radians), ha, and declination (radians), dec.
  226. X */
  227. Xvoid
  228. Xaa_hadec (lat, alt, az, ha, dec)
  229. Xdouble lat;
  230. Xdouble alt, az;
  231. Xdouble *ha, *dec;
  232. X{
  233. X    aaha_aux (lat, az, alt, ha, dec);
  234. X}
  235. X
  236. X/* given latitude (n+, radians), lat, hour angle (radians), ha, and declination
  237. X * (radians), dec,
  238. X * return altitude (up+, radians), alt, and
  239. X * azimuth (angle round to the east from north+, radians),
  240. X */
  241. Xvoid
  242. Xhadec_aa (lat, ha, dec, alt, az)
  243. Xdouble lat;
  244. Xdouble ha, dec;
  245. Xdouble *alt, *az;
  246. X{
  247. X    aaha_aux (lat, ha, dec, az, alt);
  248. X}
  249. X
  250. X/* the actual formula is the same for both transformation directions so
  251. X * do it here once for each way.
  252. X * N.B. all arguments are in radians.
  253. X */
  254. Xstatic void
  255. Xaaha_aux (lat, x, y, p, q)
  256. Xdouble lat;
  257. Xdouble x, y;
  258. Xdouble *p, *q;
  259. X{
  260. X    static double lastlat = -1000.;
  261. X    static double sinlastlat, coslastlat;
  262. X    double sy, cy;
  263. X    double sx, cx;
  264. X    double sq, cq;
  265. X    double a;
  266. X    double cp;
  267. X
  268. X    /* latitude doesn't change much, so try to reuse the sin and cos evals.
  269. X     */
  270. X    if (lat != lastlat) {
  271. X        sinlastlat = sin (lat);
  272. X        coslastlat = cos (lat);
  273. X        lastlat = lat;
  274. X    }
  275. X
  276. X    sy = sin (y);
  277. X    cy = cos (y);
  278. X    sx = sin (x);
  279. X    cx = cos (x);
  280. X
  281. X/* define GOODATAN2 if atan2 returns full range -PI through +PI.
  282. X */
  283. X#ifdef GOODATAN2
  284. X    *q = asin ((sy*sinlastlat) + (cy*coslastlat*cx));
  285. X    *p = atan2 (-cy*sx, -cy*cx*sinlastlat + sy*coslastlat);
  286. X#else
  287. X#define    EPS    (1e-20)
  288. X    sq = (sy*sinlastlat) + (cy*coslastlat*cx);
  289. X    *q = asin (sq);
  290. X    cq = cos (*q);
  291. X    a = coslastlat*cq;
  292. X    if (a > -EPS && a < EPS)
  293. X        a = a < 0 ? -EPS : EPS; /* avoid / 0 */
  294. X    cp = (sy - (sinlastlat*sq))/a;
  295. X    if (cp >= 1.0)    /* the /a can be slightly > 1 */
  296. X        *p = 0.0;
  297. X    else if (cp <= -1.0)
  298. X        *p = PI;
  299. X    else
  300. X        *p = acos ((sy - (sinlastlat*sq))/a);
  301. X    if (sx>0) *p = 2.0*PI - *p;
  302. X#endif
  303. X}
  304. END_OF_FILE
  305.   if test 2283 -ne `wc -c <'aa_hadec.c'`; then
  306.     echo shar: \"'aa_hadec.c'\" unpacked with wrong size!
  307.   fi
  308.   # end of 'aa_hadec.c'
  309. fi
  310. if test -f 'astro.h' -a "${1}" != "-c" ; then 
  311.   echo shar: Will not clobber existing file \"'astro.h'\"
  312. else
  313.   echo shar: Extracting \"'astro.h'\" \(885 characters\)
  314.   sed "s/^X//" >'astro.h' <<'END_OF_FILE'
  315. X/* defined derived strictly from the Duffett-Smith functions.
  316. X */
  317. X
  318. X#ifndef PI
  319. X#define    PI        3.141592653589793
  320. X#endif
  321. X
  322. X/* conversions among hours (of ra), degrees and radians. */
  323. X#define    degrad(x)    ((x)*PI/180.)
  324. X#define    raddeg(x)    ((x)*180./PI)
  325. X#define    hrdeg(x)    ((x)*15.)
  326. X#define    deghr(x)    ((x)/15.)
  327. X#define    hrrad(x)    degrad(hrdeg(x))
  328. X#define    radhr(x)    deghr(raddeg(x))
  329. X
  330. X/* ratio of from synodic (solar) to sidereal (stellar) rate */
  331. X#define    SIDRATE        .9972695677
  332. X
  333. X/* manifest names for planets.
  334. X * N.B. must coincide with usage in pelement.c and plans.c.
  335. X * N.B. only the first 8 are valid for use with plans().
  336. X */
  337. X#define    MERCURY    0
  338. X#define    VENUS    1
  339. X#define    MARS    2
  340. X#define    JUPITER    3
  341. X#define    SATURN    4
  342. X#define    URANUS    5
  343. X#define    NEPTUNE    6
  344. X#define    PLUTO    7
  345. X
  346. X/* a few more handy ones */
  347. X#define    SUN    8
  348. X#define    MOON    9
  349. X#define    OBJX    10
  350. X#define    OBJY    11
  351. X#define    NOBJ    12    /* total number of basic objects */
  352. END_OF_FILE
  353.   if test 885 -ne `wc -c <'astro.h'`; then
  354.     echo shar: \"'astro.h'\" unpacked with wrong size!
  355.   fi
  356.   # end of 'astro.h'
  357. fi
  358. if test -f 'eq_ecl.c' -a "${1}" != "-c" ; then 
  359.   echo shar: Will not clobber existing file \"'eq_ecl.c'\"
  360. else
  361.   echo shar: Extracting \"'eq_ecl.c'\" \(2433 characters\)
  362.   sed "s/^X//" >'eq_ecl.c' <<'END_OF_FILE'
  363. X#include <stdio.h>
  364. X#include <math.h>
  365. X#include "astro.h"
  366. X
  367. X#if defined(__STDC__) || defined(__cplusplus)
  368. X#define P_(s) s
  369. X#else
  370. X#define P_(s) ()
  371. X#endif
  372. X
  373. Xextern void nutation P_((double Mjd, double *deps, double *dpsi));
  374. Xextern void obliquity P_((double Mjd, double *eps));
  375. Xextern void range P_((double *v, double r));
  376. X
  377. Xvoid eq_ecl P_((double mjd, double ra, double dec, double *lat, double *lng));
  378. Xvoid ecl_eq P_((double mjd, double lat, double lng, double *ra, double *dec));
  379. Xstatic void ecleq_aux P_((int sw, double mjd, double x, double y, double *p, double *q));
  380. X
  381. X#undef P_
  382. X
  383. X#define    EQtoECL    1
  384. X#define    ECLtoEQ    (-1)
  385. X
  386. X/* given the modified Julian date, mjd, and an equitorial ra and dec, each in
  387. X * radians, find the corresponding geocentric ecliptic latitude, *lat, and
  388. X * longititude, *lng, also each in radians.
  389. X * correction for the effect on the angle of the obliquity due to nutation is
  390. X * included.
  391. X */
  392. Xvoid
  393. Xeq_ecl (mjd, ra, dec, lat, lng)
  394. Xdouble mjd, ra, dec;
  395. Xdouble *lat, *lng;
  396. X{
  397. X    ecleq_aux (EQtoECL, mjd, ra, dec, lng, lat);
  398. X}
  399. X
  400. X/* given the modified Julian date, mjd, and a geocentric ecliptic latitude,
  401. X * *lat, and longititude, *lng, each in radians, find the corresponding
  402. X * equitorial ra and dec, also each in radians.
  403. X * correction for the effect on the angle of the obliquity due to nutation is
  404. X * included.
  405. X */
  406. Xvoid
  407. Xecl_eq (mjd, lat, lng, ra, dec)
  408. Xdouble mjd, lat, lng;
  409. Xdouble *ra, *dec;
  410. X{
  411. X    ecleq_aux (ECLtoEQ, mjd, lng, lat, ra, dec);
  412. X}
  413. X
  414. Xstatic void
  415. Xecleq_aux (sw, mjd, x, y, p, q)
  416. Xint sw;            /* +1 for eq to ecliptic, -1 for vv. */
  417. Xdouble mjd, x, y;    /* sw==1: x==ra, y==dec.  sw==-1: x==lng, y==lat. */
  418. Xdouble *p, *q;        /* sw==1: p==lng, q==lat. sw==-1: p==ra, q==dec. */
  419. X{
  420. X    static double lastmjd = -10000;    /* last mjd calculated */
  421. X    static double seps, ceps;    /* sin and cos of mean obliquity */
  422. X    double sx, cx, sy, cy, ty;
  423. X
  424. X    if (mjd != lastmjd) {
  425. X        double eps;
  426. X        double deps, dpsi;
  427. X        obliquity (mjd, &eps);        /* mean obliquity for date */
  428. X        nutation (mjd, &deps, &dpsi);
  429. X        eps += deps;
  430. X            seps = sin(eps);
  431. X        ceps = cos(eps);
  432. X        lastmjd = mjd;
  433. X    }
  434. X
  435. X    sy = sin(y);
  436. X    cy = cos(y);                /* always non-negative */
  437. X        if (fabs(cy)<1e-20) cy = 1e-20;        /* insure > 0 */
  438. X        ty = sy/cy;
  439. X    cx = cos(x);
  440. X    sx = sin(x);
  441. X        *q = asin((sy*ceps)-(cy*seps*sx*sw));
  442. X        *p = atan(((sx*ceps)+(ty*seps*sw))/cx);
  443. X        if (cx<0) *p += PI;        /* account for atan quad ambiguity */
  444. X    range (p, 2*PI);
  445. X}
  446. END_OF_FILE
  447.   if test 2433 -ne `wc -c <'eq_ecl.c'`; then
  448.     echo shar: \"'eq_ecl.c'\" unpacked with wrong size!
  449.   fi
  450.   # end of 'eq_ecl.c'
  451. fi
  452. if test -f 'marsmap.c' -a "${1}" != "-c" ; then 
  453.   echo shar: Will not clobber existing file \"'marsmap.c'\"
  454. else
  455.   echo shar: Extracting \"'marsmap.c'\" \(1639 characters\)
  456.   sed "s/^X//" >'marsmap.c' <<'END_OF_FILE'
  457. X#include "map.h"
  458. X
  459. Xstatic MCoord mc0[] = {
  460. X    {325,-11}, {9,-10}, {10,5}, {5,2}, {0,0}, {352,2}, {348,-5}, {330,6}
  461. X};
  462. Xstatic MCoord mc1[] = {
  463. X    {160,-40}, {200,-40}, {200,-35}, {240,-15}, {235,-4}, {195,-32}, {170,-35}
  464. X};
  465. Xstatic MCoord mc2[] = {
  466. X    {220,-25},{228,-35},{240,-35},{250,-26},{260,-30},{280,-25},{282,-11},
  467. X    {280,-3},{260,-7},{245,-20},{240,-15}
  468. X};
  469. Xstatic MCoord mc3[] = {
  470. X    {281,5}, {285,1}, {298,2}, {290,22}, {283,22}
  471. X};
  472. Xstatic MCoord mc4[] = {
  473. X    {120,-32}, {140,-35}, {150,-33}, {165,-25}, {165,-22}, {162,-23},
  474. X    {142,-31}, {138,-30}
  475. X};
  476. Xstatic MCoord mc5[] = {
  477. X    {40,21}, {52,30}, {55,20}, {61,19}, {61,26}, {68,29}, {68,30}, {42,50},
  478. X    {22,48}, {10,40}, {15,35}, {20,25}
  479. X};
  480. Xstatic MCoord mc6[] = {
  481. X    {72,-28}, {82,-29}, {90,-34}, {100,-22}, {90,-17}, {80,-20}, {72,-20}
  482. X};
  483. Xstatic MCoord mc7[] = {
  484. X    {58,-28}, {68,-24}, {64,-19}, {56,-20}
  485. X};
  486. Xstatic MCoord mc8[] = {
  487. X    {20,-31}, {30,-35}, {55,-26}, {53,-20}, {30,-20}
  488. X};
  489. Xstatic MCoord mc9[] = {
  490. X    {30,-20}, {53,-20}, {65,-15}, {57,-6}, {38,-5}, {29,-16}
  491. X};
  492. Xstatic MCoord mc10[] = {
  493. X    {5,-26}, {38,-8}, {21,0}
  494. X};
  495. X
  496. X#define    ASIZ(a)        (sizeof(a)/sizeof(a[0]))
  497. X
  498. XMRegion mreg[] = {
  499. X    {"Meridiani Sinus",        mc0, ASIZ(mc0)},
  500. X    {"Cimmerium Mare",        mc1, ASIZ(mc1)},
  501. X    {"Tyrrhenum Mare",        mc2, ASIZ(mc2)},
  502. X    {"Syrtis Major",        mc3, ASIZ(mc3)},
  503. X    {"Sirenum Mare",        mc4, ASIZ(mc4)},
  504. X    {"Niliacus Lacus",        mc5, ASIZ(mc5)},
  505. X    {"Solis Lacus",        mc6, ASIZ(mc6)},
  506. X    {"Nectar",            mc7, ASIZ(mc7)},
  507. X    {"Erythraeum Mare",        mc8, ASIZ(mc8)},
  508. X    {"Aurorae Sinus",        mc9, ASIZ(mc9)},
  509. X    {"Margaritifer Sinus",    mc10, ASIZ(mc10)},
  510. X};
  511. X
  512. Xint nmreg = ASIZ(mreg);
  513. END_OF_FILE
  514.   if test 1639 -ne `wc -c <'marsmap.c'`; then
  515.     echo shar: \"'marsmap.c'\" unpacked with wrong size!
  516.   fi
  517.   # end of 'marsmap.c'
  518. fi
  519. if test -f 'moon.c' -a "${1}" != "-c" ; then 
  520.   echo shar: Will not clobber existing file \"'moon.c'\"
  521. else
  522.   echo shar: Extracting \"'moon.c'\" \(5365 characters\)
  523.   sed "s/^X//" >'moon.c' <<'END_OF_FILE'
  524. X#include <stdio.h>
  525. X#include <math.h>
  526. X#include "astro.h"
  527. X
  528. X#if defined(__STDC__) || defined(__cplusplus)
  529. X#define P_(s) s
  530. X#else
  531. X#define P_(s) ()
  532. X#endif
  533. X
  534. Xextern void range P_((double *v, double r));
  535. X
  536. Xvoid moon P_((double mjd, double *lam, double *bet, double *hp));
  537. X
  538. X#undef P_
  539. X
  540. X/* given the mjd, find the geocentric ecliptic longitude, lam, and latitude,
  541. X * bet, and horizontal parallax, hp for the moon.
  542. X * N.B. series for long and lat are good to about 10 and 3 arcseconds. however,
  543. X *   math errors cause up to 100 and 30 arcseconds error, even if use double.
  544. X *   why?? suspect highly sensitive nature of difference used to get m1..6.
  545. X * N.B. still need to correct for nutation. then for topocentric location
  546. X *   further correct for parallax and refraction.
  547. X */
  548. Xvoid
  549. Xmoon (mjd, lam, bet, hp)
  550. Xdouble mjd;
  551. Xdouble *lam, *bet, *hp;
  552. X{
  553. X    double t, t2;
  554. X    double ld;
  555. X    double ms;
  556. X    double md;
  557. X    double de;
  558. X    double f;
  559. X    double n;
  560. X    double a, sa, sn, b, sb, c, sc, e, e2, l, g, w1, w2;
  561. X    double m1, m2, m3, m4, m5, m6;
  562. X
  563. X    t = mjd/36525.;
  564. X    t2 = t*t;
  565. X
  566. X    m1 = mjd/27.32158213;
  567. X    m1 = 360.0*(m1-(long)m1);
  568. X    m2 = mjd/365.2596407;
  569. X    m2 = 360.0*(m2-(long)m2);
  570. X    m3 = mjd/27.55455094;
  571. X    m3 = 360.0*(m3-(long)m3);
  572. X    m4 = mjd/29.53058868;
  573. X    m4 = 360.0*(m4-(long)m4);
  574. X    m5 = mjd/27.21222039;
  575. X    m5 = 360.0*(m5-(long)m5);
  576. X    m6 = mjd/6798.363307;
  577. X    m6 = 360.0*(m6-(long)m6);
  578. X
  579. X    ld = 270.434164+m1-(.001133-.0000019*t)*t2;
  580. X    ms = 358.475833+m2-(.00015+.0000033*t)*t2;
  581. X    md = 296.104608+m3+(.009192+.0000144*t)*t2;
  582. X    de = 350.737486+m4-(.001436-.0000019*t)*t2;
  583. X    f = 11.250889+m5-(.003211+.0000003*t)*t2;
  584. X    n = 259.183275-m6+(.002078+.000022*t)*t2;
  585. X
  586. X    a = degrad(51.2+20.2*t);
  587. X    sa = sin(a);
  588. X    sn = sin(degrad(n));
  589. X    b = 346.56+(132.87-.0091731*t)*t;
  590. X    sb = .003964*sin(degrad(b));
  591. X    c = degrad(n+275.05-2.3*t);
  592. X    sc = sin(c);
  593. X    ld = ld+.000233*sa+sb+.001964*sn;
  594. X    ms = ms-.001778*sa;
  595. X    md = md+.000817*sa+sb+.002541*sn;
  596. X    f = f+sb-.024691*sn-.004328*sc;
  597. X    de = de+.002011*sa+sb+.001964*sn;
  598. X    e = 1-(.002495+7.52e-06*t)*t;
  599. X    e2 = e*e;
  600. X
  601. X    ld = degrad(ld);
  602. X    ms = degrad(ms);
  603. X    n = degrad(n);
  604. X    de = degrad(de);
  605. X    f = degrad(f);
  606. X    md = degrad(md);
  607. X
  608. X    l = 6.28875*sin(md)+1.27402*sin(2*de-md)+.658309*sin(2*de)+
  609. X        .213616*sin(2*md)-e*.185596*sin(ms)-.114336*sin(2*f)+
  610. X        .058793*sin(2*(de-md))+.057212*e*sin(2*de-ms-md)+
  611. X        .05332*sin(2*de+md)+.045874*e*sin(2*de-ms)+.041024*e*sin(md-ms);
  612. X    l = l-.034718*sin(de)-e*.030465*sin(ms+md)+.015326*sin(2*(de-f))-
  613. X        .012528*sin(2*f+md)-.01098*sin(2*f-md)+.010674*sin(4*de-md)+
  614. X        .010034*sin(3*md)+.008548*sin(4*de-2*md)-e*.00791*sin(ms-md+2*de)-
  615. X        e*.006783*sin(2*de+ms);
  616. X    l = l+.005162*sin(md-de)+e*.005*sin(ms+de)+.003862*sin(4*de)+
  617. X        e*.004049*sin(md-ms+2*de)+.003996*sin(2*(md+de))+
  618. X        .003665*sin(2*de-3*md)+e*.002695*sin(2*md-ms)+
  619. X        .002602*sin(md-2*(f+de))+e*.002396*sin(2*(de-md)-ms)-
  620. X        .002349*sin(md+de);
  621. X    l = l+e2*.002249*sin(2*(de-ms))-e*.002125*sin(2*md+ms)-
  622. X        e2*.002079*sin(2*ms)+e2*.002059*sin(2*(de-ms)-md)-
  623. X        .001773*sin(md+2*(de-f))-.001595*sin(2*(f+de))+
  624. X        e*.00122*sin(4*de-ms-md)-.00111*sin(2*(md+f))+.000892*sin(md-3*de);
  625. X    l = l-e*.000811*sin(ms+md+2*de)+e*.000761*sin(4*de-ms-2*md)+
  626. X         e2*.000704*sin(md-2*(ms+de))+e*.000693*sin(ms-2*(md-de))+
  627. X         e*.000598*sin(2*(de-f)-ms)+.00055*sin(md+4*de)+.000538*sin(4*md)+
  628. X         e*.000521*sin(4*de-ms)+.000486*sin(2*md-de);
  629. X    l = l+e2*.000717*sin(md-2*ms);
  630. X    *lam = ld+degrad(l);
  631. X    range (lam, 2*PI);
  632. X
  633. X    g = 5.12819*sin(f)+.280606*sin(md+f)+.277693*sin(md-f)+
  634. X        .173238*sin(2*de-f)+.055413*sin(2*de+f-md)+.046272*sin(2*de-f-md)+
  635. X        .032573*sin(2*de+f)+.017198*sin(2*md+f)+.009267*sin(2*de+md-f)+
  636. X        .008823*sin(2*md-f)+e*.008247*sin(2*de-ms-f);
  637. X    g = g+.004323*sin(2*(de-md)-f)+.0042*sin(2*de+f+md)+
  638. X        e*.003372*sin(f-ms-2*de)+e*.002472*sin(2*de+f-ms-md)+
  639. X        e*.002222*sin(2*de+f-ms)+e*.002072*sin(2*de-f-ms-md)+
  640. X        e*.001877*sin(f-ms+md)+.001828*sin(4*de-f-md)-e*.001803*sin(f+ms)-
  641. X        .00175*sin(3*f);
  642. X    g = g+e*.00157*sin(md-ms-f)-.001487*sin(f+de)-e*.001481*sin(f+ms+md)+
  643. X         e*.001417*sin(f-ms-md)+e*.00135*sin(f-ms)+.00133*sin(f-de)+
  644. X         .001106*sin(f+3*md)+.00102*sin(4*de-f)+.000833*sin(f+4*de-md)+
  645. X         .000781*sin(md-3*f)+.00067*sin(f+4*de-2*md);
  646. X    g = g+.000606*sin(2*de-3*f)+.000597*sin(2*(de+md)-f)+
  647. X        e*.000492*sin(2*de+md-ms-f)+.00045*sin(2*(md-de)-f)+
  648. X        .000439*sin(3*md-f)+.000423*sin(f+2*(de+md))+
  649. X        .000422*sin(2*de-f-3*md)-e*.000367*sin(ms+f+2*de-md)-
  650. X        e*.000353*sin(ms+f+2*de)+.000331*sin(f+4*de);
  651. X    g = g+e*.000317*sin(2*de+f-ms+md)+e2*.000306*sin(2*(de-ms)-f)-
  652. X        .000283*sin(md+3*f);
  653. X    w1 = .0004664*cos(n);
  654. X    w2 = .0000754*cos(c);
  655. X    *bet = degrad(g)*(1-w1-w2);
  656. X
  657. X    *hp = .950724+.051818*cos(md)+.009531*cos(2*de-md)+.007843*cos(2*de)+
  658. X          .002824*cos(2*md)+.000857*cos(2*de+md)+e*.000533*cos(2*de-ms)+
  659. X          e*.000401*cos(2*de-md-ms)+e*.00032*cos(md-ms)-.000271*cos(de)-
  660. X          e*.000264*cos(ms+md)-.000198*cos(2*f-md);
  661. X    *hp = *hp+.000173*cos(3*md)+.000167*cos(4*de-md)-e*.000111*cos(ms)+
  662. X         .000103*cos(4*de-2*md)-.000084*cos(2*md-2*de)-
  663. X         e*.000083*cos(2*de+ms)+.000079*cos(2*de+2*md)+.000072*cos(4*de)+
  664. X         e*.000064*cos(2*de-ms+md)-e*.000063*cos(2*de+ms-md)+
  665. X         e*.000041*cos(ms+de);
  666. X    *hp = *hp+e*.000035*cos(2*md-ms)-.000033*cos(3*md-2*de)-
  667. X         .00003*cos(md+de)-.000029*cos(2*(f-de))-e*.000029*cos(2*md+ms)+
  668. X         e2*.000026*cos(2*(de-ms))-.000023*cos(2*(f-de)+md)+
  669. X         e*.000019*cos(4*de-ms-md);
  670. X    *hp = degrad(*hp);
  671. X}
  672. END_OF_FILE
  673.   if test 5365 -ne `wc -c <'moon.c'`; then
  674.     echo shar: \"'moon.c'\" unpacked with wrong size!
  675.   fi
  676.   # end of 'moon.c'
  677. fi
  678. if test -f 'moonnf.c' -a "${1}" != "-c" ; then 
  679.   echo shar: Will not clobber existing file \"'moonnf.c'\"
  680. else
  681.   echo shar: Extracting \"'moonnf.c'\" \(1918 characters\)
  682.   sed "s/^X//" >'moonnf.c' <<'END_OF_FILE'
  683. X#include <stdio.h>
  684. X#include <math.h>
  685. X#include "astro.h"
  686. X
  687. X#if defined(__STDC__) || defined(__cplusplus)
  688. X#define P_(s) s
  689. X#else
  690. X#define P_(s) ()
  691. X#endif
  692. X
  693. Xextern void cal_mjd P_((int mn, double dy, int yr, double *Mjd));
  694. Xextern void mjd_cal P_((double Mjd, int *mn, double *dy, int *yr));
  695. X
  696. Xvoid moonnf P_((double mjd, double *mjdn, double *mjdf));
  697. Xstatic void m P_((double t, double k, double *mjd));
  698. X
  699. X#undef P_
  700. X
  701. X#define    unw(w,z)    ((w)-floor((w)/(z))*(z))
  702. X
  703. X/* given a modified Julian date, mjd, return the mjd of the new
  704. X * and full moons about then, mjdn and mjdf.
  705. X * TODO: exactly which ones does it find? eg:
  706. X *   5/28/1988 yields 5/15 and 5/31
  707. X *   5/29             6/14     6/29
  708. X */
  709. Xvoid
  710. Xmoonnf (mjd, mjdn, mjdf)
  711. Xdouble mjd;
  712. Xdouble *mjdn, *mjdf;
  713. X{
  714. X    int mo, yr;
  715. X    double dy;
  716. X    double mjd0;
  717. X    double k, tn, tf, t;
  718. X
  719. X    mjd_cal (mjd, &mo, &dy, &yr);
  720. X    cal_mjd (1, 0., yr, &mjd0);
  721. X    k = (yr-1900+((mjd-mjd0)/365))*12.3685;
  722. X    k = floor(k+0.5);
  723. X    tn = k/1236.85;
  724. X    tf = (k+0.5)/1236.85;
  725. X    t = tn;
  726. X    m (t, k, mjdn);
  727. X    t = tf;
  728. X    k += 0.5;
  729. X    m (t, k, mjdf);
  730. X}
  731. X
  732. Xstatic void
  733. Xm (t, k, mjd)
  734. Xdouble t, k;
  735. Xdouble *mjd;
  736. X{
  737. X    double t2, a, a1, b, b1, c, ms, mm, f, ddjd;
  738. X
  739. X    t2 = t*t;
  740. X    a = 29.53*k;
  741. X    c = degrad(166.56+(132.87-9.173e-3*t)*t);
  742. X    b = 5.8868e-4*k+(1.178e-4-1.55e-7*t)*t2+3.3e-4*sin(c)+7.5933E-1;
  743. X    ms = 359.2242+360*unw(k/1.236886e1,1)-(3.33e-5+3.47e-6*t)*t2;
  744. X    mm = 306.0253+360*unw(k/9.330851e-1,1)+(1.07306e-2+1.236e-5*t)*t2;
  745. X    f = 21.2964+360*unw(k/9.214926e-1,1)-(1.6528e-3+2.39e-6*t)*t2;
  746. X    ms = unw(ms,360);
  747. X    mm = unw(mm,360);
  748. X    f = unw(f,360);
  749. X    ms = degrad(ms);
  750. X    mm = degrad(mm);
  751. X    f = degrad(f);
  752. X    ddjd = (1.734e-1-3.93e-4*t)*sin(ms)+2.1e-3*sin(2*ms)
  753. X        -4.068e-1*sin(mm)+1.61e-2*sin(2*mm)-4e-4*sin(3*mm)
  754. X        +1.04e-2*sin(2*f)-5.1e-3*sin(ms+mm)-7.4e-3*sin(ms-mm)
  755. X        +4e-4*sin(2*f+ms)-4e-4*sin(2*f-ms)-6e-4*sin(2*f+mm)
  756. X        +1e-3*sin(2*f-mm)+5e-4*sin(ms+2*mm);
  757. X    a1 = (long)a;
  758. X    b = b+ddjd+(a-a1);
  759. X    b1 = (long)b;
  760. X    a = a1+b1;
  761. X    b = b-b1;
  762. X    *mjd = a + b;
  763. X}
  764. END_OF_FILE
  765.   if test 1918 -ne `wc -c <'moonnf.c'`; then
  766.     echo shar: \"'moonnf.c'\" unpacked with wrong size!
  767.   fi
  768.   # end of 'moonnf.c'
  769. fi
  770. if test -f 'msgmenu.c' -a "${1}" != "-c" ; then 
  771.   echo shar: Will not clobber existing file \"'msgmenu.c'\"
  772. else
  773.   echo shar: Extracting \"'msgmenu.c'\" \(7013 characters\)
  774.   sed "s/^X//" >'msgmenu.c' <<'END_OF_FILE'
  775. X/* this file contains the code to put up misc messages: xe_msg().
  776. X * everything goes to stdout and into the message dialog.
  777. X * the latter can be toggled on/off from the main menu.
  778. X */
  779. X
  780. X#include <stdio.h>
  781. X#include <ctype.h>
  782. X#include <math.h>
  783. X#if defined(__STDC__)
  784. X#include <stdlib.h>
  785. X#endif
  786. X#include <X11/Xlib.h>
  787. X#include <Xm/Xm.h>
  788. X#include <Xm/Form.h>
  789. X#include <Xm/PushB.h>
  790. X#include <Xm/Text.h>
  791. X#include <Xm/MessageB.h>
  792. X
  793. X#if defined(__STDC__) || defined(__cplusplus)
  794. X#define P_(s) s
  795. X#else
  796. X#define P_(s) ()
  797. X#endif
  798. X
  799. Xextern void prompt_map_cb P_((Widget w, XtPointer client, XtPointer call));
  800. Xextern void set_something P_((Widget w, char *resource, char *value));
  801. Xextern void set_xmstring P_((Widget w, char *resource, char *txt));
  802. X
  803. Xvoid msg_manage P_((void));
  804. Xvoid xe_msg P_((char *msg, int app_modal));
  805. Xvoid msg_cursor P_((Cursor c));
  806. Xstatic void msg_on_top P_((void));
  807. Xstatic void msg_create_w P_((void));
  808. Xstatic void msg_erase_cb P_((Widget w, XtPointer client, XtPointer call));
  809. Xstatic void msg_close_cb P_((Widget w, XtPointer client, XtPointer call));
  810. Xstatic void msg_add P_((char *msg));
  811. Xstatic void msg_scroll_down P_((void));
  812. Xstatic void msg_stdout P_((char *msg));
  813. Xstatic void xe_msg_modal P_((char *p));
  814. X
  815. X#undef P_
  816. X
  817. Xextern Widget toplevel_w;
  818. X
  819. Xstatic Widget msg_w;        /* main form dialog widget */
  820. Xstatic Widget txt_w;        /* scrolled text widget */
  821. Xstatic int txtl;        /* current length of text in txt_w */
  822. X
  823. X/* called to force the scrolling message window to be up.
  824. X * bring it down if it already is.
  825. X */
  826. Xvoid
  827. Xmsg_manage()
  828. X{
  829. X    if (!msg_w)
  830. X        msg_create_w();
  831. X
  832. X    if (!XtIsManaged(msg_w))
  833. X        XtManageChild (msg_w);
  834. X    else
  835. X        XtUnmanageChild (msg_w);
  836. X}
  837. X
  838. X/* if app_modal != 0
  839. X *   make an application modal info box,
  840. X * else
  841. X *   create dialog if not already made.
  842. X *   add message to the scrolling text window.
  843. X *   also write message to stdout.
  844. X */
  845. Xvoid
  846. Xxe_msg (msg, app_modal)
  847. Xchar *msg;
  848. Xint app_modal;
  849. X{
  850. X    if (app_modal) {
  851. X        xe_msg_modal (msg);
  852. X        return;
  853. X    }
  854. X
  855. X    if (!msg_w)
  856. X        msg_create_w();
  857. X    msg_add (msg);
  858. X
  859. X    /* if we are managed we bully right under the cursor. */
  860. X    if (XtIsManaged(msg_w))
  861. X        msg_on_top();
  862. X
  863. X    msg_stdout (msg);
  864. X}
  865. X
  866. X/* called to put up or remove the watch cursor.  */
  867. Xvoid
  868. Xmsg_cursor (c)
  869. XCursor c;
  870. X{
  871. X    Window win;
  872. X
  873. X    if (msg_w && (win = XtWindow(msg_w))) {
  874. X        Display *dsp = XtDisplay(msg_w);
  875. X        if (c)
  876. X        XDefineCursor (dsp, win, c);
  877. X        else
  878. X        XUndefineCursor (dsp, win);
  879. X    }
  880. X}
  881. X
  882. X/* do everything we can to make sure the message dialog is visible.
  883. X */
  884. Xstatic void
  885. Xmsg_on_top()
  886. X{
  887. X    Window win;
  888. X
  889. X    /* bring to the top right under the cursor
  890. X     * N.B. we can't if this is the first time but don't need to in that
  891. X     *   case anyway because that means nothing is on top of us yet.
  892. X     */
  893. X    win = XtWindow(XtParent(msg_w));
  894. X    if (win) {
  895. X        XRaiseWindow(XtDisplay(XtParent(msg_w)), win);
  896. X        XtCallCallbacks (msg_w, XmNmapCallback, NULL);
  897. X    }
  898. X
  899. X    XFlush (XtDisplay(msg_w));
  900. X}
  901. X
  902. X/* create the message dialog */
  903. Xstatic void
  904. Xmsg_create_w()
  905. X{
  906. X    static struct {
  907. X        char *name;
  908. X        void (*cb)();
  909. X    } cb[] = {
  910. X        {"Erase", msg_erase_cb},
  911. X        {"Close", msg_close_cb},
  912. X    };
  913. X    Widget w;
  914. X    Arg args[20];
  915. X    int i, n;
  916. X
  917. X    /* make the help shell form-dialog widget */
  918. X
  919. X    n = 0;
  920. X    XtSetArg (args[n], XmNdefaultPosition, False); n++;
  921. X    XtSetArg (args[n], XmNautoUnmanage, False); n++;
  922. X    XtSetArg (args[n], XmNfractionBase, 9); n++;
  923. X    msg_w = XmCreateFormDialog (toplevel_w, "Message", args, n);
  924. X    XtAddCallback (msg_w, XmNmapCallback, prompt_map_cb, NULL);
  925. X    set_something (XtParent(msg_w), XmNtitle, "xephem Message");
  926. X
  927. X    /* make the control buttons */
  928. X
  929. X    for (i = 0; i < XtNumber(cb); i++) {
  930. X        n = 0;
  931. X        XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  932. X        XtSetArg (args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
  933. X        XtSetArg (args[n], XmNleftPosition, 1 + 5*i); n++;
  934. X        XtSetArg (args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
  935. X        XtSetArg (args[n], XmNrightPosition, 3 + 5*i); n++;
  936. X        w = XmCreatePushButton (msg_w, cb[i].name, args, n);
  937. X        XtAddCallback (w, XmNactivateCallback, cb[i].cb, NULL);
  938. X        XtManageChild (w);
  939. X    }
  940. X
  941. X    /* make the scrolled text area to hold the messages */
  942. X
  943. X    n = 0;
  944. X    XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  945. X    XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
  946. X    XtSetArg (args[n], XmNbottomWidget, w); n++;
  947. X    XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  948. X    XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  949. X    XtSetArg (args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
  950. X    XtSetArg (args[n], XmNeditable, False); n++;
  951. X    XtSetArg (args[n], XmNcursorPositionVisible, False); n++;
  952. X    txt_w = XmCreateScrolledText (msg_w, "ScrolledText", args, n);
  953. X    XtManageChild (txt_w);
  954. X}
  955. X
  956. X/* callback from the erase pushbutton */
  957. X/* ARGSUSED */
  958. Xstatic void
  959. Xmsg_erase_cb (w, client, call)
  960. XWidget w;
  961. XXtPointer client;
  962. XXtPointer call;
  963. X{
  964. X    XmTextReplace (txt_w, 0, txtl, "");
  965. X    txtl = 0;
  966. X    XFlush (XtDisplay(msg_w));
  967. X}
  968. X
  969. X/* callback from the close pushbutton */
  970. X/* ARGSUSED */
  971. Xstatic void
  972. Xmsg_close_cb (w, client, call)
  973. XWidget w;
  974. XXtPointer client;
  975. XXtPointer call;
  976. X{
  977. X    XtUnmanageChild (msg_w);
  978. X}
  979. X
  980. X/* add msg to the txt_w widget.
  981. X * Always set the vertical scroll bar to the extreme bottom.
  982. X */
  983. Xstatic void
  984. Xmsg_add (msg)
  985. Xchar *msg;
  986. X{
  987. X    int l;
  988. X
  989. X    l = strlen(msg);
  990. X    if (l == 0)
  991. X        return;
  992. X
  993. X    XmTextReplace (txt_w, txtl, txtl, msg);
  994. X    txtl += l;
  995. X
  996. X    if (msg[l-1] != '\n')
  997. X        msg_add ("\n");
  998. X    else
  999. X        msg_scroll_down();
  1000. X}
  1001. X
  1002. X/* make sure the text is scrolled to the bottom */
  1003. Xstatic void
  1004. Xmsg_scroll_down()
  1005. X{
  1006. X    XmTextSetInsertionPosition (txt_w, txtl);
  1007. X}
  1008. X
  1009. X/* write msg to stdout. 
  1010. X * add newline if one is not already at the end of msg[].
  1011. X */
  1012. Xstatic void
  1013. Xmsg_stdout (msg)
  1014. Xchar *msg;
  1015. X{
  1016. X    int l = strlen(msg);
  1017. X
  1018. X    printf ("%s", msg);
  1019. X    if (l > 0 && msg[l-1] != '\n')
  1020. X        (void) putchar ('\n');
  1021. X    (void) fflush (stdout);
  1022. X}
  1023. X
  1024. X/* print a message, p, in an app-modal dialog. */
  1025. Xstatic void
  1026. Xxe_msg_modal (p)
  1027. Xchar *p;
  1028. X{
  1029. X    static Widget apmsg_w;
  1030. X    Arg args[20];
  1031. X    int n;
  1032. X
  1033. X    if (!apmsg_w) {
  1034. X        XmString button_string;
  1035. X        XmString title_string;
  1036. X        Widget w;
  1037. X
  1038. X        button_string = XmStringCreate("Ok", XmSTRING_DEFAULT_CHARSET);
  1039. X        title_string = XmStringCreate ("xephem Modal Message",
  1040. X                        XmSTRING_DEFAULT_CHARSET);
  1041. X
  1042. X        /* Create MessageBox dialog. */
  1043. X        n = 0;
  1044. X        XtSetArg (args[n], XmNdefaultPosition, False);  n++;
  1045. X        XtSetArg (args[n], XmNtitle, "xephem Modal Message");  n++;
  1046. X        XtSetArg (args[n], XmNokLabelString, button_string);  n++;
  1047. X        XtSetArg (args[n], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); n++;
  1048. X        apmsg_w = XmCreateWarningDialog (toplevel_w, "message", args, n);
  1049. X        XtAddCallback (apmsg_w, XmNmapCallback, prompt_map_cb, NULL);
  1050. X
  1051. X        XmStringFree (title_string);
  1052. X        XmStringFree (button_string);
  1053. X
  1054. X        w = XmMessageBoxGetChild (apmsg_w, XmDIALOG_CANCEL_BUTTON);
  1055. X        XtUnmanageChild (w);
  1056. X        w = XmMessageBoxGetChild (apmsg_w, XmDIALOG_HELP_BUTTON);
  1057. X        XtUnmanageChild (w);
  1058. X    }
  1059. X
  1060. X    set_xmstring (apmsg_w, XmNmessageString, p);
  1061. X
  1062. X    /* Display help window. rely on autoUnmanage to bring back down. */
  1063. X    XtManageChild (apmsg_w);
  1064. X}
  1065. END_OF_FILE
  1066.   if test 7013 -ne `wc -c <'msgmenu.c'`; then
  1067.     echo shar: \"'msgmenu.c'\" unpacked with wrong size!
  1068.   fi
  1069.   # end of 'msgmenu.c'
  1070. fi
  1071. if test -f 'nutation.c' -a "${1}" != "-c" ; then 
  1072.   echo shar: Will not clobber existing file \"'nutation.c'\"
  1073. else
  1074.   echo shar: Extracting \"'nutation.c'\" \(2135 characters\)
  1075.   sed "s/^X//" >'nutation.c' <<'END_OF_FILE'
  1076. X#include <stdio.h>
  1077. X#include <math.h>
  1078. X#include "astro.h"
  1079. X#include "preferences.h"
  1080. X
  1081. X/* given the modified JD, mjd, find the nutation in obliquity, *deps, and
  1082. X * the nutation in longitude, *dpsi, each in radians.
  1083. X */
  1084. Xvoid
  1085. Xnutation (mjd, deps, dpsi)
  1086. Xdouble mjd;
  1087. Xdouble *deps, *dpsi;
  1088. X{
  1089. X    static double lastmjd = -10000, lastdeps, lastdpsi;
  1090. X    double ls, ld;    /* sun's mean longitude, moon's mean longitude */
  1091. X    double ms, md;    /* sun's mean anomaly, moon's mean anomaly */
  1092. X    double nm;    /* longitude of moon's ascending node */
  1093. X    double t, t2;    /* number of Julian centuries of 36525 days since
  1094. X             * Jan 0.5 1900.
  1095. X             */
  1096. X    double tls, tnm, tld;    /* twice above */
  1097. X    double a, b;    /* temps */
  1098. X
  1099. X    if (pref_get(PREF_ALGO) == PREF_FAST) {
  1100. X        *deps = 0.0;
  1101. X        *dpsi = 0.0;
  1102. X        return;
  1103. X    }
  1104. X
  1105. X    if (mjd == lastmjd) {
  1106. X        *deps = lastdeps;
  1107. X        *dpsi = lastdpsi;
  1108. X        return;
  1109. X    }
  1110. X        
  1111. X    t = mjd/36525.;
  1112. X    t2 = t*t;
  1113. X
  1114. X    a = 100.0021358*t;
  1115. X    b = 360.*(a-(long)a);
  1116. X    ls = 279.697+.000303*t2+b;
  1117. X
  1118. X    a = 1336.855231*t;
  1119. X    b = 360.*(a-(long)a);
  1120. X    ld = 270.434-.001133*t2+b;
  1121. X
  1122. X    a = 99.99736056000026*t;
  1123. X    b = 360.*(a-(long)a);
  1124. X    ms = 358.476-.00015*t2+b;
  1125. X
  1126. X    a = 13255523.59*t;
  1127. X    b = 360.*(a-(long)a);
  1128. X    md = 296.105+.009192*t2+b;
  1129. X
  1130. X    a = 5.372616667*t;
  1131. X    b = 360.*(a-(long)a);
  1132. X    nm = 259.183+.002078*t2-b;
  1133. X
  1134. X    /* convert to radian forms for use with trig functions.
  1135. X     */
  1136. X    tls = 2*degrad(ls);
  1137. X    nm = degrad(nm);
  1138. X    tnm = 2*nm;
  1139. X    ms = degrad(ms);
  1140. X    tld = 2*degrad(ld);
  1141. X    md = degrad(md);
  1142. X
  1143. X    /* find delta psi and eps, in arcseconds.
  1144. X     */
  1145. X    lastdpsi = (-17.2327-.01737*t)*sin(nm)+(-1.2729-.00013*t)*sin(tls)
  1146. X           +.2088*sin(tnm)-.2037*sin(tld)+(.1261-.00031*t)*sin(ms)
  1147. X           +.0675*sin(md)-(.0497-.00012*t)*sin(tls+ms)
  1148. X           -.0342*sin(tld-nm)-.0261*sin(tld+md)+.0214*sin(tls-ms)
  1149. X           -.0149*sin(tls-tld+md)+.0124*sin(tls-nm)+.0114*sin(tld-md);
  1150. X    lastdeps = (9.21+.00091*t)*cos(nm)+(.5522-.00029*t)*cos(tls)
  1151. X           -.0904*cos(tnm)+.0884*cos(tld)+.0216*cos(tls+ms)
  1152. X           +.0183*cos(tld-nm)+.0113*cos(tld+md)-.0093*cos(tls-ms)
  1153. X           -.0066*cos(tls-nm);
  1154. X
  1155. X    /* convert to radians.
  1156. X     */
  1157. X    lastdpsi = degrad(lastdpsi/3600);
  1158. X    lastdeps = degrad(lastdeps/3600);
  1159. X
  1160. X    lastmjd = mjd;
  1161. X    *deps = lastdeps;
  1162. X    *dpsi = lastdpsi;
  1163. X}
  1164. END_OF_FILE
  1165.   if test 2135 -ne `wc -c <'nutation.c'`; then
  1166.     echo shar: \"'nutation.c'\" unpacked with wrong size!
  1167.   fi
  1168.   # end of 'nutation.c'
  1169. fi
  1170. if test -f 'obliq.c' -a "${1}" != "-c" ; then 
  1171.   echo shar: Will not clobber existing file \"'obliq.c'\"
  1172. else
  1173.   echo shar: Extracting \"'obliq.c'\" \(426 characters\)
  1174.   sed "s/^X//" >'obliq.c' <<'END_OF_FILE'
  1175. X#include <stdio.h>
  1176. X#include "astro.h"
  1177. X
  1178. X/* given the modified Julian date, mjd, find the obliquity of the
  1179. X * ecliptic, *eps, in radians.
  1180. X */
  1181. Xvoid
  1182. Xobliquity (mjd, eps)
  1183. Xdouble mjd;
  1184. Xdouble *eps;
  1185. X{
  1186. X    static double lastmjd = -10000, lasteps;
  1187. X
  1188. X    if (mjd != lastmjd) {
  1189. X        double t;
  1190. X        t = mjd/36525.;
  1191. X        lasteps = degrad(2.345229444E1
  1192. X            - ((((-1.81E-3*t)+5.9E-3)*t+4.6845E1)*t)/3600.0);
  1193. X        lastmjd = mjd;
  1194. X    }
  1195. X    *eps = lasteps;
  1196. X}
  1197. END_OF_FILE
  1198.   if test 426 -ne `wc -c <'obliq.c'`; then
  1199.     echo shar: \"'obliq.c'\" unpacked with wrong size!
  1200.   fi
  1201.   # end of 'obliq.c'
  1202. fi
  1203. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  1204.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  1205. else
  1206.   echo shar: Extracting \"'patchlevel.h'\" \(266 characters\)
  1207.   sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  1208. X/* this string constant defines the current version of xephem.
  1209. X * it is used by versionmenu.c to display the version in the Intro banner.
  1210. X * it is also updated by any subsequent patches that are issued for xephem.
  1211. X */
  1212. X
  1213. X#define    PATCHLEVEL    "Version 2.4b May 10, 1993"
  1214. END_OF_FILE
  1215.   if test 266 -ne `wc -c <'patchlevel.h'`; then
  1216.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  1217.   fi
  1218.   # end of 'patchlevel.h'
  1219. fi
  1220. if test -f 'pelement.c' -a "${1}" != "-c" ; then 
  1221.   echo shar: Will not clobber existing file \"'pelement.c'\"
  1222. else
  1223.   echo shar: Extracting \"'pelement.c'\" \(5005 characters\)
  1224.   sed "s/^X//" >'pelement.c' <<'END_OF_FILE'
  1225. X#include <stdio.h>
  1226. X#include <math.h>
  1227. X#include "astro.h"
  1228. X
  1229. X#if defined(__STDC__) || defined(__cplusplus)
  1230. X#define P_(s) s
  1231. X#else
  1232. X#define P_(s) ()
  1233. X#endif
  1234. X
  1235. Xextern void range P_((double *v, double r));
  1236. X
  1237. Xvoid pelement P_((double mjd, double plan[8][9]));
  1238. X
  1239. X#undef P_
  1240. X
  1241. X
  1242. X/* this array contains polynomial coefficients to find the various orbital
  1243. X *   elements for the mean orbit at any instant in time for each major planet.
  1244. X *   the first five elements are in the form a0 + a1*t + a2*t**2 + a3*t**3,
  1245. X *   where t is the number of Julian centuries of 36525 Julian days since 1900
  1246. X *   Jan 0.5. the last three elements are constants.
  1247. X *
  1248. X * the orbital element (column) indeces are:
  1249. X *   [ 0- 3]: coefficients for mean longitude, in degrees;
  1250. X *   [ 4- 7]: coefficients for longitude of the perihelion, in degrees;
  1251. X *   [ 8-11]: coefficients for eccentricity;
  1252. X *   [12-15]: coefficients for inclination, in degrees;
  1253. X *   [16-19]: coefficients for longitude of the ascending node, in degrees;
  1254. X *      [20]: semi-major axis, in AU;
  1255. X *      [21]: angular diameter at 1 AU, in arcsec;
  1256. X *      [22]: standard visual magnitude, ie, the visual magnitude of the planet
  1257. X *          when at a distance of 1 AU from both the Sun and the Earth and
  1258. X *          with zero phase angle.
  1259. X *
  1260. X * the planent (row) indeces are:
  1261. X *   [0]: Mercury; [1]: Venus;   [2]: Mars;  [3]: Jupiter; [4]: Saturn;
  1262. X *   [5]: Uranus;  [6]: Neptune; [7]: Pluto.
  1263. X */
  1264. X#define    NPELE    (5*4 + 3)    /* 4 coeffs for ea of 5 elems, + 3 constants */
  1265. Xstatic double elements[8][NPELE] = {
  1266. X
  1267. X    {   /*     mercury... */
  1268. X
  1269. X        178.179078,    415.2057519,    3.011e-4,    0.0,
  1270. X        75.899697,    1.5554889,    2.947e-4,    0.0,
  1271. X        .20561421,    2.046e-5,    3e-8,        0.0,
  1272. X        7.002881,    1.8608e-3,    -1.83e-5,    0.0,
  1273. X        47.145944,    1.1852083,    1.739e-4,    0.0,
  1274. X        .3870986,    6.74,         -0.42
  1275. X    },
  1276. X
  1277. X    {   /*     venus... */
  1278. X
  1279. X        342.767053,    162.5533664,    3.097e-4,    0.0,
  1280. X        130.163833,    1.4080361,    -9.764e-4,    0.0,
  1281. X        6.82069e-3,    -4.774e-5,    9.1e-8,        0.0,
  1282. X        3.393631,    1.0058e-3,    -1e-6,        0.0,
  1283. X        75.779647,    .89985,        4.1e-4,        0.0,
  1284. X        .7233316,    16.92,        -4.4
  1285. X    },
  1286. X
  1287. X    {   /*     mars... */
  1288. X
  1289. X        293.737334,    53.17137642,    3.107e-4,    0.0,
  1290. X        3.34218203e2, 1.8407584,    1.299e-4,    -1.19e-6,
  1291. X        9.33129e-2,    9.2064e-5,    7.7e-8,        0.0,
  1292. X        1.850333,    -6.75e-4,    1.26e-5,    0.0,
  1293. X        48.786442,    .7709917,    -1.4e-6,    -5.33e-6,
  1294. X        1.5236883,    9.36,        -1.52
  1295. X    },
  1296. X
  1297. X    {   /*     jupiter... */
  1298. X
  1299. X        238.049257,    8.434172183,    3.347e-4,    -1.65e-6,
  1300. X        1.2720972e1, 1.6099617,    1.05627e-3,    -3.43e-6,
  1301. X        4.833475e-2, 1.6418e-4,    -4.676e-7,    -1.7e-9,
  1302. X        1.308736,    -5.6961e-3,    3.9e-6,        0.0,
  1303. X        99.443414,    1.01053,    3.5222e-4,    -8.51e-6,
  1304. X        5.202561,    196.74,        -9.4
  1305. X    },
  1306. X
  1307. X    {   /*     saturn... */
  1308. X
  1309. X        266.564377,    3.398638567,    3.245e-4,    -5.8e-6,
  1310. X        9.1098214e1, 1.9584158,    8.2636e-4,    4.61e-6,
  1311. X        5.589232e-2, -3.455e-4,    -7.28e-7,    7.4e-10,
  1312. X        2.492519,    -3.9189e-3,    -1.549e-5,    4e-8,
  1313. X        112.790414,    .8731951,    -1.5218e-4,    -5.31e-6,
  1314. X        9.554747,    165.6,        -8.88
  1315. X    },
  1316. X
  1317. X    {   /*     uranus... */
  1318. X
  1319. X        244.19747,    1.194065406,    3.16e-4,    -6e-7,
  1320. X        1.71548692e2, 1.4844328,    2.372e-4,    -6.1e-7,
  1321. X        4.63444e-2,    -2.658e-5,    7.7e-8,        0.0,
  1322. X        .772464,    6.253e-4,    3.95e-5,    0.0,
  1323. X        73.477111,    .4986678,    1.3117e-3,    0.0,
  1324. X        19.21814,    65.8,        -7.19
  1325. X    },
  1326. X
  1327. X    {   /*     neptune... */
  1328. X
  1329. X        84.457994,    .6107942056,    3.205e-4,    -6e-7,
  1330. X        4.6727364e1, 1.4245744,    3.9082e-4,    -6.05e-7,
  1331. X        8.99704e-3,    6.33e-6,    -2e-9,        0.0,
  1332. X        1.779242,    -9.5436e-3,    -9.1e-6,    0.0,
  1333. X        130.681389,    1.098935,    2.4987e-4,    -4.718e-6,
  1334. X        30.10957,    62.2,        -6.87
  1335. X    },
  1336. X
  1337. X    {   /*     pluto...(osculating 1984 jan 21) */
  1338. X
  1339. X        95.3113544,    .3980332167,    0.0,        0.0,
  1340. X        224.017,    0.0,        0.0,        0.0,
  1341. X        .25515,    0.0,        0.0,        0.0,
  1342. X        17.1329,    0.0,        0.0,        0.0,
  1343. X        110.191,    0.0,        0.0,        0.0,
  1344. X        39.8151,    8.2,        -1.0
  1345. X    }
  1346. X};
  1347. X
  1348. X/* given a modified Julian date, mjd, return the elements for the mean orbit
  1349. X *   at that instant of all the major planets, together with their
  1350. X *   mean daily motions in longitude, angular diameter and standard visual
  1351. X *   magnitude.
  1352. X * plan[i][j] contains all the values for all the planets at mjd, such that
  1353. X *   i = 0..7: mercury, venus, mars, jupiter, saturn, unranus, neptune, pluto;
  1354. X *   j = 0..8: mean longitude, mean daily motion in longitude, longitude of 
  1355. X *     the perihelion, eccentricity, inclination, longitude of the ascending
  1356. X *     node, length of the semi-major axis, angular diameter from 1 AU, and
  1357. X *     the standard visual magnitude (see elements[][] comment, above).
  1358. X */
  1359. Xvoid
  1360. Xpelement (mjd, plan)
  1361. Xdouble mjd;
  1362. Xdouble plan[8][9];
  1363. X{
  1364. X    register double *ep, *pp;
  1365. X    register double t = mjd/36525.;
  1366. X    double aa;
  1367. X    int planet, i;
  1368. X
  1369. X    for (planet = 0; planet < 8; planet++) {
  1370. X        ep = elements[planet];
  1371. X        pp = plan[planet];
  1372. X        aa = ep[1]*t;
  1373. X        pp[0] = ep[0] + 360.*(aa-(long)aa) + (ep[3]*t + ep[2])*t*t;
  1374. X        range (pp, 360.);
  1375. X        pp[1] = (ep[1]*9.856263e-3) + (ep[2] + ep[3])/36525;
  1376. X
  1377. X        for (i = 4; i < 20; i += 4)
  1378. X        pp[i/4+1] = ((ep[i+3]*t + ep[i+2])*t + ep[i+1])*t + ep[i+0];
  1379. X
  1380. X        pp[6] = ep[20];
  1381. X        pp[7] = ep[21];
  1382. X        pp[8] = ep[22];
  1383. X    }
  1384. X}
  1385. END_OF_FILE
  1386.   if test 5005 -ne `wc -c <'pelement.c'`; then
  1387.     echo shar: \"'pelement.c'\" unpacked with wrong size!
  1388.   fi
  1389.   # end of 'pelement.c'
  1390. fi
  1391. if test -f 'reduce.c' -a "${1}" != "-c" ; then 
  1392.   echo shar: Will not clobber existing file \"'reduce.c'\"
  1393. else
  1394.   echo shar: Extracting \"'reduce.c'\" \(1974 characters\)
  1395.   sed "s/^X//" >'reduce.c' <<'END_OF_FILE'
  1396. X#include <math.h>
  1397. X#include "astro.h"
  1398. X
  1399. X
  1400. X#if defined(__STDC__) || defined(__cplusplus)
  1401. X#define P_(s) s
  1402. X#else
  1403. X#define P_(s) ()
  1404. X#endif
  1405. X
  1406. Xextern void range P_((double *v, double r));
  1407. X
  1408. Xvoid reduce_elements P_((double mjd0, double mjd, double inc0, double ap0, double om0, double *inc, double *ap, double *om));
  1409. X
  1410. X#undef P_
  1411. X
  1412. X/* convert those orbital elements that change from epoch mjd0 to epoch mjd.
  1413. X */
  1414. Xvoid
  1415. Xreduce_elements (mjd0, mjd, inc0, ap0, om0, inc, ap, om)
  1416. Xdouble mjd0;    /* initial epoch */
  1417. Xdouble mjd;    /* desired epoch */
  1418. Xdouble inc0;    /* initial inclination, rads */
  1419. Xdouble ap0;    /* initial argument of perihelion, as an mjd */
  1420. Xdouble om0;    /* initial long of ascending node, rads */
  1421. Xdouble *inc;    /* desired inclination, rads */
  1422. Xdouble *ap;    /* desired epoch of perihelion, as an mjd */
  1423. Xdouble *om;    /* desired long of ascending node, rads */
  1424. X{
  1425. X    double t0, t1;
  1426. X    double tt, tt2, t02, tt3;
  1427. X    double eta, th, th0;
  1428. X    double a, b;
  1429. X    double dap;
  1430. X    double cinc, sinc;
  1431. X    double ot, sot, cot, ot1;
  1432. X    double seta, ceta;
  1433. X
  1434. X    t0 = mjd0/365250.0;
  1435. X    t1 = mjd/365250.0;
  1436. X
  1437. X    tt = t1-t0;
  1438. X    tt2 = tt*tt;
  1439. X        t02 = t0*t0;
  1440. X    tt3 = tt*tt2;
  1441. X        eta = (471.07-6.75*t0+.57*t02)*tt+(.57*t0-3.37)*tt2+.05*tt3;
  1442. X        th0 = 32869.0*t0+56*t02-(8694+55*t0)*tt+3*tt2;
  1443. X        eta = degrad(eta/3600.0);
  1444. X        th0 = degrad((th0/3600.0)+173.950833);
  1445. X        th = (50256.41+222.29*t0+.26*t02)*tt+(111.15+.26*t0)*tt2+.1*tt3;
  1446. X        th = th0+degrad(th/3600.0);
  1447. X    cinc = cos(inc0);
  1448. X        sinc = sin(inc0);
  1449. X    ot = om0-th0;
  1450. X    sot = sin(ot);
  1451. X        cot = cos(ot);
  1452. X    seta = sin(eta);
  1453. X        ceta = cos(eta);
  1454. X    a = sinc*sot;
  1455. X        b = ceta*sinc*cot-seta*cinc;
  1456. X    ot1 = atan(a/b);
  1457. X        if (b<0) ot1 += PI;
  1458. X        b = sinc*ceta-cinc*seta*cot;
  1459. X        a = -1*seta*sot;
  1460. X    dap = atan(a/b);
  1461. X        if (b<0) dap += PI;
  1462. X
  1463. X        *ap = ap0+dap;
  1464. X    range (ap, 2*PI);
  1465. X        *om = ot1+th;
  1466. X    range (om, 2*PI);
  1467. X
  1468. X        if (inc0<.175)
  1469. X        *inc = asin(a/sin(dap));
  1470. X    else
  1471. X        *inc = 1.570796327-asin((cinc*ceta)+(sinc*seta*cot));
  1472. X}
  1473. END_OF_FILE
  1474.   if test 1974 -ne `wc -c <'reduce.c'`; then
  1475.     echo shar: \"'reduce.c'\" unpacked with wrong size!
  1476.   fi
  1477.   # end of 'reduce.c'
  1478. fi
  1479. if test -f 'refract.c' -a "${1}" != "-c" ; then 
  1480.   echo shar: Will not clobber existing file \"'refract.c'\"
  1481. else
  1482.   echo shar: Extracting \"'refract.c'\" \(1867 characters\)
  1483.   sed "s/^X//" >'refract.c' <<'END_OF_FILE'
  1484. X#include <stdio.h>
  1485. X#include <math.h>
  1486. X#include "astro.h"
  1487. X
  1488. X/* correct the true altitude, ta, for refraction to the apparent altitude, aa,
  1489. X * each in radians, given the local atmospheric pressure, pr, in mbars, and
  1490. X * the temperature, tr, in degrees C.
  1491. X */
  1492. Xvoid
  1493. Xrefract (pr, tr, ta, aa)
  1494. Xdouble pr, tr;
  1495. Xdouble ta;
  1496. Xdouble *aa;
  1497. X{
  1498. X    double r;    /* refraction correction*/
  1499. X
  1500. X        if (ta >= degrad(15.)) {
  1501. X        /* model for altitudes at least 15 degrees above horizon */
  1502. X            r = 7.888888e-5*pr/((273+tr)*tan(ta));
  1503. X    } else if (ta > degrad(-5.)) {
  1504. X        /* hairier model for altitudes at least -5 and below 15 degrees */
  1505. X        double a, b, tadeg = raddeg(ta);
  1506. X        a = ((2e-5*tadeg+1.96e-2)*tadeg+1.594e-1)*pr;
  1507. X        b = (273+tr)*((8.45e-2*tadeg+5.05e-1)*tadeg+1);
  1508. X        r = degrad(a/b);
  1509. X    } else {
  1510. X        /* do nothing if more than 5 degrees below horizon.
  1511. X         */
  1512. X        r = 0;
  1513. X    }
  1514. X
  1515. X    *aa  =  ta + r;
  1516. X}
  1517. X
  1518. X/* correct the apparent altitude, aa, for refraction to the true altitude, ta,
  1519. X * each in radians, given the local atmospheric pressure, pr, in mbars, and
  1520. X * the temperature, tr, in degrees C.
  1521. X */
  1522. Xvoid
  1523. Xunrefract (pr, tr, aa, ta)
  1524. Xdouble pr, tr;
  1525. Xdouble aa;
  1526. Xdouble *ta;
  1527. X{
  1528. X    double err;
  1529. X    double appar;
  1530. X    double true;
  1531. X
  1532. X    /* iterative solution: search for the true that refracts to the
  1533. X     *   given apparent.
  1534. X     * since refract() is discontinuous at -5 degrees, there is a range
  1535. X     *   of apparent altitudes between about -4.5 and -5 degrees that are
  1536. X     *   not invertable (the graph of ap vs. true has a vertical step at
  1537. X     *   true = -5). thus, the iteration just oscillates if it gets into
  1538. X     *   this region. if this happens the iteration is forced to abort.
  1539. X     *   of course, this makes unrefract() discontinuous too.
  1540. X     */
  1541. X    true = aa;
  1542. X    do {
  1543. X        refract (pr, tr, true, &appar);
  1544. X        err = appar - aa;
  1545. X        true -= err;
  1546. X    } while (fabs(err) >= 1e-6 && true > degrad(-5));
  1547. X
  1548. X    *ta = true;
  1549. X}
  1550. END_OF_FILE
  1551.   if test 1867 -ne `wc -c <'refract.c'`; then
  1552.     echo shar: \"'refract.c'\" unpacked with wrong size!
  1553.   fi
  1554.   # end of 'refract.c'
  1555. fi
  1556. if test -f 'riset.c' -a "${1}" != "-c" ; then 
  1557.   echo shar: Will not clobber existing file \"'riset.c'\"
  1558. else
  1559.   echo shar: Extracting \"'riset.c'\" \(4887 characters\)
  1560.   sed "s/^X//" >'riset.c' <<'END_OF_FILE'
  1561. X#include <stdio.h>
  1562. X#include <math.h>
  1563. X#include "astro.h"
  1564. X
  1565. X#if defined(__STDC__) || defined(__cplusplus)
  1566. X#define P_(s) s
  1567. X#else
  1568. X#define P_(s) ()
  1569. X#endif
  1570. X
  1571. Xextern void range P_((double *v, double r));
  1572. X
  1573. Xvoid riset P_((double ra, double dec, double lat, double dis, double *lstr, double *lsts, double *azr, double *azs, int *status));
  1574. X
  1575. X#undef P_
  1576. X
  1577. X
  1578. X/* given the true geocentric ra and dec of an object, the observer's latitude,
  1579. X *   lat, and a horizon displacement correction, dis, all in radians, find the
  1580. X *   local sidereal times and azimuths of rising and setting, lstr/s
  1581. X *   and azr/s, also all in radians, respectively.
  1582. X * dis is the vertical displacement from the true position of the horizon. it
  1583. X *   is positive if the apparent position is lower than the true position.
  1584. X *   said another way, it is positive if the shift causes the object to spend
  1585. X *   longer above the horizon. for example, atmospheric refraction is typically
  1586. X *   assumed to produce a vertical shift of 34 arc minutes at the horizon; dis
  1587. X *   would then take on the value +9.89e-3 (radians). On the other hand, if
  1588. X *   your horizon has hills such that your apparent horizon is, say, 1 degree
  1589. X *   above sea level, you would allow for this by setting dis to -1.75e-2
  1590. X *   (radians).
  1591. X *
  1592. X * algorithm:
  1593. X *   the situation is described by two spherical triangles with two equal angles
  1594. X *    (the right horizon intercepts, and the common horizon transverse):
  1595. X *   given lat, d(=d1+d2), and dis find z(=z1+z2) and rho, where      /| eq pole
  1596. X *     lat = latitude,                                              /  |
  1597. X *     dis = horizon displacement (>0 is below ideal)             / rho|
  1598. X *     d = angle from pole = PI/2 - declination                /       |
  1599. X *     z = azimuth east of north                            /          |
  1600. X *     rho = polar rotation from down = PI - hour angle    /           | 
  1601. X *   solve simultaneous equations for d1 and d2:         /             |
  1602. X *     1) cos(d) = cos(d1+d2)                           / d2           | lat
  1603. X *            = cos(d1)cos(d2) - sin(d1)sin(d2)        /               |
  1604. X *     2) sin(d2) = sin(lat)sin(d1)/sin(dis)          /                |
  1605. X *   then can solve for z1, z2 and rho, taking       /                 |
  1606. X *     care to preserve quadrant information.       /                 -|
  1607. X *                                              z1 /        z2       | |
  1608. X *                      ideal horizon ------------/--------------------| 
  1609. X *                                         | |   /                     N
  1610. X *                                          -|  / d1
  1611. X *                                       dis | /
  1612. X *                                           |/
  1613. X *                  apparent horizon  ---------------------------------
  1614. X *
  1615. X * note that when lat=0 this all breaks down (because d2 and z2 degenerate to 0)
  1616. X *   but fortunately then we can solve for z and rho directly.
  1617. X *
  1618. X * status: 0: normal; 1: never rises; -1: circumpolar; 2: trouble.
  1619. X */
  1620. Xvoid
  1621. Xriset (ra, dec, lat, dis, lstr, lsts, azr, azs, status)
  1622. Xdouble ra, dec;
  1623. Xdouble lat, dis;
  1624. Xdouble *lstr, *lsts;
  1625. Xdouble *azr, *azs;
  1626. Xint *status;
  1627. X{
  1628. X#define    EPS    (1e-6)    /* math rounding fudge - always the way, eh? */
  1629. X    double d;    /* angle from pole */
  1630. X    double h;    /* hour angle */
  1631. X    double crho;    /* cos hour-angle complement */
  1632. X    int shemi;    /* flag for southern hemisphere reflection */
  1633. X
  1634. X    d = PI/2 - dec;
  1635. X
  1636. X    /* reflect if in southern hemisphere.
  1637. X     * (then reflect azimuth back after computation.)
  1638. X     */
  1639. X    if ((shemi = (lat < 0)) != 0) {
  1640. X        lat = -lat;
  1641. X        d = PI - d;
  1642. X    }
  1643. X
  1644. X    /* do the easy ones (and avoid violated assumptions) if d arc never
  1645. X     * meets horizon. 
  1646. X     */
  1647. X    if (d <= lat + dis + EPS) {
  1648. X        *status = -1; /* never sets */
  1649. X        return;
  1650. X    }
  1651. X    if (d >= PI - lat + dis - EPS) {
  1652. X        *status = 1; /* never rises */
  1653. X        return;
  1654. X    }
  1655. X
  1656. X    /* find rising azimuth and cosine of hour-angle complement */
  1657. X    if (lat > EPS) {
  1658. X        double d2, d1; /* polr arc to ideal hzn, and corrctn for apparent */
  1659. X        double z2, z1; /* azimuth to ideal horizon, and " */
  1660. X        double a;       /* intermediate temp */
  1661. X        double sdis, slat, clat, cz2, cd2;    /* trig temps */
  1662. X        sdis = sin(dis);
  1663. X        slat = sin(lat);
  1664. X        a = sdis*sdis + slat*slat + 2*cos(d)*sdis*slat;
  1665. X        if (a <= 0) {
  1666. X        *status = 2; /* can't happen - hah! */
  1667. X        return;
  1668. X        }
  1669. X        d1 = asin (sin(d) * sdis / sqrt(a));
  1670. X        d2 = d - d1;
  1671. X        cd2 = cos(d2);
  1672. X        clat = cos(lat);
  1673. X        cz2 = cd2/clat;
  1674. X        z2 = acos (cz2);
  1675. X        z1 = acos (cos(d1)/cos(dis));
  1676. X        if (dis < 0)
  1677. X        z1 = -z1;
  1678. X        *azr = z1 + z2;
  1679. X        range (azr, PI);
  1680. X        crho = (cz2 - cd2*clat)/(sin(d2)*slat);
  1681. X    } else {
  1682. X        *azr = acos (cos(d)/cos(dis));
  1683. X        crho = sin(dis)/sin(d);
  1684. X    }
  1685. X
  1686. X    if (shemi)
  1687. X        *azr = PI - *azr;
  1688. X        *azs = 2*PI - *azr;
  1689. X    
  1690. X    /* find hour angle */
  1691. X    h = PI - acos (crho);
  1692. X        *lstr = radhr(ra-h);
  1693. X    *lsts = radhr(ra+h);
  1694. X    range (lstr, 24.0);
  1695. X    range (lsts, 24.0);
  1696. X
  1697. X    *status = 0;
  1698. X}
  1699. END_OF_FILE
  1700.   if test 4887 -ne `wc -c <'riset.c'`; then
  1701.     echo shar: \"'riset.c'\" unpacked with wrong size!
  1702.   fi
  1703.   # end of 'riset.c'
  1704. fi
  1705. if test -f 'sun.c' -a "${1}" != "-c" ; then 
  1706.   echo shar: Will not clobber existing file \"'sun.c'\"
  1707. else
  1708.   echo shar: Extracting \"'sun.c'\" \(2228 characters\)
  1709.   sed "s/^X//" >'sun.c' <<'END_OF_FILE'
  1710. X#include <stdio.h>
  1711. X#include <math.h>
  1712. X#include "astro.h"
  1713. X
  1714. X#if defined(__STDC__) || defined(__cplusplus)
  1715. X#define P_(s) s
  1716. X#else
  1717. X#define P_(s) ()
  1718. X#endif
  1719. X
  1720. Xextern void anomaly P_((double ma, double s, double *nu, double *ea));
  1721. Xextern void range P_((double *v, double r));
  1722. X
  1723. Xvoid sunpos P_((double mjd, double *lsn, double *rsn));
  1724. X
  1725. X#undef P_
  1726. X
  1727. X
  1728. X/* given the modified JD, mjd, return the true geocentric ecliptic longitude
  1729. X *   of the sun for the mean equinox of the date, *lsn, in radians, and the
  1730. X *   sun-earth distance, *rsn, in AU. (the true ecliptic latitude is never more
  1731. X *   than 1.2 arc seconds and so may be taken to be a constant 0.)
  1732. X * if the APPARENT ecliptic longitude is required, correct the longitude for
  1733. X *   nutation to the true equinox of date and for aberration (light travel time,
  1734. X *   approximately  -9.27e7/186000/(3600*24*365)*2*pi = -9.93e-5 radians).
  1735. X */
  1736. Xvoid
  1737. Xsunpos (mjd, lsn, rsn)
  1738. Xdouble mjd;
  1739. Xdouble *lsn, *rsn;
  1740. X{
  1741. X    static double last_mjd = -3691, last_lsn, last_rsn;
  1742. X    double t, t2;
  1743. X    double ls, ms;    /* mean longitude and mean anomoay */
  1744. X    double s, nu, ea; /* eccentricity, true anomaly, eccentric anomaly */
  1745. X    double a, b, a1, b1, c1, d1, e1, h1, dl, dr;
  1746. X
  1747. X    if (mjd == last_mjd) {
  1748. X        *lsn = last_lsn;
  1749. X        *rsn = last_rsn;
  1750. X        return;
  1751. X    }
  1752. X
  1753. X    t = mjd/36525.;
  1754. X    t2 = t*t;
  1755. X    a = 100.0021359*t;
  1756. X    b = 360.*(a-(long)a);
  1757. X    ls = 279.69668+.0003025*t2+b;
  1758. X    a = 99.99736042000039*t;
  1759. X    b = 360*(a-(long)a);
  1760. X    ms = 358.47583-(.00015+.0000033*t)*t2+b;
  1761. X    s = .016751-.0000418*t-1.26e-07*t2;
  1762. X    anomaly (degrad(ms), s, &nu, &ea);
  1763. X    a = 62.55209472000015*t;
  1764. X    b = 360*(a-(long)a);
  1765. X    a1 = degrad(153.23+b);
  1766. X    a = 125.1041894*t;
  1767. X    b = 360*(a-(long)a);
  1768. X    b1 = degrad(216.57+b);
  1769. X    a = 91.56766028*t;
  1770. X    b = 360*(a-(long)a);
  1771. X    c1 = degrad(312.69+b);
  1772. X    a = 1236.853095*t;
  1773. X    b = 360*(a-(long)a);
  1774. X    d1 = degrad(350.74-.00144*t2+b);
  1775. X    e1 = degrad(231.19+20.2*t);
  1776. X    a = 183.1353208*t;
  1777. X    b = 360*(a-(long)a);
  1778. X    h1 = degrad(353.4+b);
  1779. X    dl = .00134*cos(a1)+.00154*cos(b1)+.002*cos(c1)+.00179*sin(d1)+
  1780. X                                .00178*sin(e1);
  1781. X    dr = 5.43e-06*sin(a1)+1.575e-05*sin(b1)+1.627e-05*sin(c1)+
  1782. X                        3.076e-05*cos(d1)+9.27e-06*sin(h1);
  1783. X    *lsn = nu+degrad(ls-ms+dl);
  1784. X    range (lsn, 2*PI);
  1785. X    last_lsn = *lsn;
  1786. X    *rsn = last_rsn = 1.0000002*(1-s*cos(ea))+dr;
  1787. X    last_mjd = mjd;
  1788. X}
  1789. END_OF_FILE
  1790.   if test 2228 -ne `wc -c <'sun.c'`; then
  1791.     echo shar: \"'sun.c'\" unpacked with wrong size!
  1792.   fi
  1793.   # end of 'sun.c'
  1794. fi
  1795. if test -f 'utc_gst.c' -a "${1}" != "-c" ; then 
  1796.   echo shar: Will not clobber existing file \"'utc_gst.c'\"
  1797. else
  1798.   echo shar: Extracting \"'utc_gst.c'\" \(1600 characters\)
  1799.   sed "s/^X//" >'utc_gst.c' <<'END_OF_FILE'
  1800. X#include "astro.h"
  1801. X
  1802. X#if defined(__STDC__) || defined(__cplusplus)
  1803. X#define P_(s) s
  1804. X#else
  1805. X#define P_(s) ()
  1806. X#endif
  1807. X
  1808. Xextern void cal_mjd P_((int mn, double dy, int yr, double *Mjd));
  1809. Xextern void mjd_cal P_((double Mjd, int *mn, double *dy, int *yr));
  1810. Xextern void range P_((double *v, double r));
  1811. X
  1812. Xvoid utc_gst P_((double mjd, double utc, double *gst));
  1813. Xvoid gst_utc P_((double mjd, double gst, double *utc));
  1814. Xstatic double tnaught P_((double mjd));
  1815. X
  1816. X#undef P_
  1817. X
  1818. X
  1819. X
  1820. X/* given a modified julian date, mjd, and a universally coordinated time, utc,
  1821. X * return greenwich mean siderial time, *gst.
  1822. X */
  1823. Xvoid
  1824. Xutc_gst (mjd, utc, gst)
  1825. Xdouble mjd;
  1826. Xdouble utc;
  1827. Xdouble *gst;
  1828. X{
  1829. X    static double lastmjd = -10000;
  1830. X    static double t0;
  1831. X
  1832. X    if (mjd != lastmjd) {
  1833. X        t0 = tnaught (mjd);
  1834. X        lastmjd = mjd;
  1835. X    }
  1836. X    *gst = (1.0/SIDRATE)*utc + t0;
  1837. X    range (gst, 24.0);
  1838. X}
  1839. X
  1840. X/* given a modified julian date, mjd, and a greenwich mean siderial time, gst,
  1841. X * return universally coordinated time, *utc.
  1842. X */
  1843. Xvoid
  1844. Xgst_utc (mjd, gst, utc)
  1845. Xdouble mjd;
  1846. Xdouble gst;
  1847. Xdouble *utc;
  1848. X{
  1849. X    static double lastmjd = -10000;
  1850. X    static double t0;
  1851. X
  1852. X    if (mjd != lastmjd) {
  1853. X        t0 = tnaught (mjd);
  1854. X        range (&t0, 24.0);
  1855. X        lastmjd = mjd;
  1856. X    }
  1857. X    *utc = gst - t0;
  1858. X    range (utc, 24.0);
  1859. X    *utc *= SIDRATE;
  1860. X}
  1861. X
  1862. Xstatic double
  1863. Xtnaught (mjd)
  1864. Xdouble mjd;    /* julian days since 1900 jan 0.5 */
  1865. X{
  1866. X    double dmjd;
  1867. X    int m, y;
  1868. X    double d;
  1869. X    double t, t0;
  1870. X
  1871. X    mjd_cal (mjd, &m, &d, &y);
  1872. X    cal_mjd (1, 0., y, &dmjd);
  1873. X    t = dmjd/36525;
  1874. X    t0 = 6.57098e-2 * (mjd - dmjd) - 
  1875. X         (24 - (6.6460656 + (5.1262e-2 + (t * 2.581e-5))*t) -
  1876. X           (2400 * (t - (((double)y - 1900)/100))));
  1877. X    return (t0);
  1878. X}
  1879. END_OF_FILE
  1880.   if test 1600 -ne `wc -c <'utc_gst.c'`; then
  1881.     echo shar: \"'utc_gst.c'\" unpacked with wrong size!
  1882.   fi
  1883.   # end of 'utc_gst.c'
  1884. fi
  1885. echo shar: End of archive 21 \(of 21\).
  1886. cp /dev/null ark21isdone
  1887. MISSING=""
  1888. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
  1889.     if test ! -f ark${I}isdone ; then
  1890.     MISSING="${MISSING} ${I}"
  1891.     fi
  1892. done
  1893. if test "${MISSING}" = "" ; then
  1894.     echo You have unpacked all 21 archives.
  1895.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1896.     echo Building ephem.db
  1897.     cat > ephem.db.Z.uu ephem.db.Z.uu.?
  1898.     uudecode ephem.db.Z.uu
  1899.     rm ephem.db.Z.uu ephem.db.Z.uu.?
  1900.     uncompress ephem.db.Z
  1901.     echo Building skyviewmenu.c
  1902.     cat > skyviewmenu.c skyviewmenu.c.?
  1903.     rm skyviewmenu.c.?
  1904.     echo Building smallfm.xbm
  1905.     cat > smallfm.xbm smallfm.xbm.?
  1906.     rm smallfm.xbm.?
  1907. else
  1908.     echo You still must unpack the following archives:
  1909.     echo "        " ${MISSING}
  1910. fi
  1911. exit 0
  1912. exit 0 # Just in case...
  1913. -- 
  1914.   // chris@IMD.Sterling.COM            | Send comp.sources.x submissions to:
  1915. \X/  Amiga - The only way to fly!      |
  1916.  "It's intuitively obvious to the most |    sources-x@imd.sterling.com
  1917.   casual observer..."                  |
  1918.