home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume28
/
ephem
/
part09
< prev
next >
Wrap
Text File
|
1992-03-15
|
28KB
|
1,026 lines
Newsgroups: comp.sources.misc
From: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
Subject: v28i092: ephem - an interactive astronomical ephemeris, v4.28, Part09/09
Message-ID: <1992Mar10.220013.16464@sparky.imd.sterling.com>
X-Md4-Signature: 94d4c1c83e3a49ba4ac9b39e91110545
Date: Tue, 10 Mar 1992 22:00:13 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
Posting-number: Volume 28, Issue 92
Archive-name: ephem/part09
Environment: UNIX, VMS, DOS, MAC
Supersedes: ephem-4.21: Volume 14, Issue 76-81
#! /bin/sh
# into a shell via "sh file" or similar. To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# Contents: Makefile aa_hadec.c anomaly.c astro.h eq_ecl.c man.a.hdr
# man.b.hdr moonnf.c obliq.c parallax.c popup.c reduce.c sex_dec.c
# sun.c utc_gst.c
# Wrapped by kent@sparky on Tue Mar 10 14:34:10 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo ' "shar: End of archive 9 (of 9)."'
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(1380 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile for ephem, v 4.28
X
XCFLAGS = -O
X
XEPHEM= aa_hadec.o altj.o altmenus.o anomaly.o cal_mjd.o circum.o comet.o \
X compiler.o constel.o eq_ecl.o flog.o formats.o io.o listing.o main.o \
X mainmenu.o moon.o moonnf.o nutation.o objx.o obliq.o parallax.o \
X pelement.o plans.o plot.o popup.o precess.o reduce.o refract.o \
X riset.o riset_c.o sel_fld.o sex_dec.o srch.o sun.o time.o utc_gst.o \
X version.o watch.o
X
Xephem: $(EPHEM)
X cc -o $@ $(EPHEM) -ltermcap -lm
X
Xaa_hadec.o: astro.h
X
Xaltj.o: astro.h circum.h screen.h
X
Xaltmenus.o: astro.h circum.h screen.h
X
Xanomaly.o: astro.h
X
Xcal_mjd.o: astro.h
X
Xcircum.o: astro.h circum.h screen.h
X
Xcomet.o: astro.h
X
Xcompiler.o: screen.h
X
Xconstel.o: astro.h circum.h screen.h
X
Xeq_ecl.o: astro.h
X
Xflog.o: screen.h
X
Xformats.o: astro.h screen.h
X
Xio.o: screen.h
X
Xlisting.o: screen.h
X
Xmain.o: astro.h circum.h screen.h
X
Xmainmenu.o: astro.h circum.h screen.h
X
Xmoon.o: astro.h
X
Xmoonnf.o: astro.h
X
Xnutation.o: astro.h
X
Xobjx.o: astro.h circum.h screen.h
X
Xobliq.o: astro.h
X
Xparallax.o: astro.h
X
Xpelement.o: astro.h
X
Xplans.o: astro.h
X
Xplot.o: screen.h
X
Xpopup.o: screen.h
X
Xprecess.o: astro.h
X
Xreduce.o: astro.h
X
Xrefract.o: astro.h
X
Xriset.o: astro.h
X
Xriset_c.o: astro.h circum.h screen.h
X
Xsel_fld.o: screen.h
X
Xsrch.o: screen.h
X
Xsun.o: astro.h
X
Xtime.o: astro.h circum.h
X
Xutc_gst.o: astro.h
X
Xversion.o: screen.h
X
Xwatch.o: astro.h circum.h screen.h
END_OF_FILE
if test 1380 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'aa_hadec.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'aa_hadec.c'\"
else
echo shar: Extracting \"'aa_hadec.c'\" \(1922 characters\)
sed "s/^X//" >'aa_hadec.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <math.h>
X#include "astro.h"
X
X/* given latitude (n+, radians), lat, altitude (up+, radians), alt, and
X * azimuth (angle round to the east from north+, radians),
X * return hour angle (radians), ha, and declination (radians), dec.
X */
Xaa_hadec (lat, alt, az, ha, dec)
Xdouble lat;
Xdouble alt, az;
Xdouble *ha, *dec;
X{
X aaha_aux (lat, az, alt, ha, dec);
X}
X
X/* given latitude (n+, radians), lat, hour angle (radians), ha, and declination
X * (radians), dec,
X * return altitude (up+, radians), alt, and
X * azimuth (angle round to the east from north+, radians),
X */
Xhadec_aa (lat, ha, dec, alt, az)
Xdouble lat;
Xdouble ha, dec;
Xdouble *alt, *az;
X{
X aaha_aux (lat, ha, dec, az, alt);
X}
X
X/* the actual formula is the same for both transformation directions so
X * do it here once for each way.
X * N.B. all arguments are in radians.
X */
Xstatic
Xaaha_aux (lat, x, y, p, q)
Xdouble lat;
Xdouble x, y;
Xdouble *p, *q;
X{
X static double lastlat = -1000.;
X static double sinlastlat, coslastlat;
X double sy, cy;
X double sx, cx;
X double sq, cq;
X double a;
X double cp;
X
X /* latitude doesn't change much, so try to reuse the sin and cos evals.
X */
X if (lat != lastlat) {
X sinlastlat = sin (lat);
X coslastlat = cos (lat);
X lastlat = lat;
X }
X
X sy = sin (y);
X cy = cos (y);
X sx = sin (x);
X cx = cos (x);
X
X/* define GOODATAN2 if atan2 returns full range -PI through +PI.
X */
X#ifdef GOODATAN2
X *q = asin ((sy*sinlastlat) + (cy*coslastlat*cx));
X *p = atan2 (-cy*sx, -cy*cx*sinlastlat + sy*coslastlat);
X#else
X#define EPS (1e-20)
X sq = (sy*sinlastlat) + (cy*coslastlat*cx);
X *q = asin (sq);
X cq = cos (*q);
X a = coslastlat*cq;
X if (a > -EPS && a < EPS)
X a = a < 0 ? -EPS : EPS; /* avoid / 0 */
X cp = (sy - (sinlastlat*sq))/a;
X if (cp >= 1.0) /* the /a can be slightly > 1 */
X *p = 0.0;
X else if (cp <= -1.0)
X *p = PI;
X else
X *p = acos ((sy - (sinlastlat*sq))/a);
X if (sx>0) *p = 2.0*PI - *p;
X#endif
X}
END_OF_FILE
if test 1922 -ne `wc -c <'aa_hadec.c'`; then
echo shar: \"'aa_hadec.c'\" unpacked with wrong size!
fi
# end of 'aa_hadec.c'
fi
if test -f 'anomaly.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'anomaly.c'\"
else
echo shar: Extracting \"'anomaly.c'\" \(901 characters\)
sed "s/^X//" >'anomaly.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <math.h>
X#include "astro.h"
X
X#define TWOPI (2*PI)
X
X/* given the mean anomaly, ma, and the eccentricity, s, of elliptical motion,
X * find the true anomaly, *nu, and the eccentric anomaly, *ea.
X * all angles in radians.
X */
Xanomaly (ma, s, nu, ea)
Xdouble ma, s;
Xdouble *nu, *ea;
X{
X double m, fea;
X
X m = ma-TWOPI*(long)(ma/TWOPI);
X if (m > PI) m -= TWOPI;
X if (m < -PI) m += TWOPI;
X fea = m;
X
X if (s < 1.0) {
X /* elliptical */
X double dla;
X while (1) {
X dla = fea-(s*sin(fea))-m;
X if (fabs(dla)<1e-6)
X break;
X dla /= 1-(s*cos(fea));
X fea -= dla;
X }
X *nu = 2*atan(sqrt((1+s)/(1-s))*tan(fea/2));
X } else {
X /* hyperbolic */
X double corr = 1;
X while (fabs(corr) > 0.000001) {
X corr = (m - s * sinh(fea) + fea) / (s*cosh(fea) - 1);
X fea += corr;
X }
X *nu = 2*atan(sqrt((s+1)/(s-1))*tanh(fea/2));
X }
X *ea = fea;
X}
END_OF_FILE
if test 901 -ne `wc -c <'anomaly.c'`; then
echo shar: \"'anomaly.c'\" unpacked with wrong size!
fi
# end of 'anomaly.c'
fi
if test -f 'astro.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'astro.h'\"
else
echo shar: Extracting \"'astro.h'\" \(620 characters\)
sed "s/^X//" >'astro.h' <<'END_OF_FILE'
X#ifndef PI
X#define PI 3.141592653589793
X#endif
X
X/* conversions among hours (of ra), degrees and radians. */
X#define degrad(x) ((x)*PI/180.)
X#define raddeg(x) ((x)*180./PI)
X#define hrdeg(x) ((x)*15.)
X#define deghr(x) ((x)/15.)
X#define hrrad(x) degrad(hrdeg(x))
X#define radhr(x) deghr(raddeg(x))
X
X/* ratio of from synodic (solar) to sidereal (stellar) rate */
X#define SIDRATE .9972695677
X
X/* manifest names for planets.
X * N.B. must cooincide with usage in pelement.c and plans.c.
X */
X#define MERCURY 0
X#define VENUS 1
X#define MARS 2
X#define JUPITER 3
X#define SATURN 4
X#define URANUS 5
X#define NEPTUNE 6
X#define PLUTO 7
END_OF_FILE
if test 620 -ne `wc -c <'astro.h'`; then
echo shar: \"'astro.h'\" unpacked with wrong size!
fi
# end of 'astro.h'
fi
if test -f 'eq_ecl.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'eq_ecl.c'\"
else
echo shar: Extracting \"'eq_ecl.c'\" \(1899 characters\)
sed "s/^X//" >'eq_ecl.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <math.h>
X#include "astro.h"
X
X#define EQtoECL 1
X#define ECLtoEQ (-1)
X
X/* given the modified Julian date, mjd, and an equitorial ra and dec, each in
X * radians, find the corresponding geocentric ecliptic latitude, *lat, and
X * longititude, *lng, also each in radians.
X * correction for the effect on the angle of the obliquity due to nutation is
X * included.
X */
Xeq_ecl (mjd, ra, dec, lat, lng)
Xdouble mjd, ra, dec;
Xdouble *lat, *lng;
X{
X ecleq_aux (EQtoECL, mjd, ra, dec, lng, lat);
X}
X
X/* given the modified Julian date, mjd, and a geocentric ecliptic latitude,
X * *lat, and longititude, *lng, each in radians, find the corresponding
X * equitorial ra and dec, also each in radians.
X * correction for the effect on the angle of the obliquity due to nutation is
X * included.
X */
Xecl_eq (mjd, lat, lng, ra, dec)
Xdouble mjd, lat, lng;
Xdouble *ra, *dec;
X{
X ecleq_aux (ECLtoEQ, mjd, lng, lat, ra, dec);
X}
X
Xstatic
Xecleq_aux (sw, mjd, x, y, p, q)
Xint sw; /* +1 for eq to ecliptic, -1 for vv. */
Xdouble mjd, x, y; /* sw==1: x==ra, y==dec. sw==-1: x==lng, y==lat. */
Xdouble *p, *q; /* sw==1: p==lng, q==lat. sw==-1: p==ra, q==dec. */
X{
X static double lastmjd = -10000; /* last mjd calculated */
X static double seps, ceps; /* sin and cos of mean obliquity */
X double sx, cx, sy, cy, ty;
X
X if (mjd != lastmjd) {
X double eps;
X double deps, dpsi;
X obliquity (mjd, &eps); /* mean obliquity for date */
X nutation (mjd, &deps, &dpsi);
X eps += deps;
X seps = sin(eps);
X ceps = cos(eps);
X lastmjd = mjd;
X }
X
X sy = sin(y);
X cy = cos(y); /* always non-negative */
X if (fabs(cy)<1e-20) cy = 1e-20; /* insure > 0 */
X ty = sy/cy;
X cx = cos(x);
X sx = sin(x);
X *q = asin((sy*ceps)-(cy*seps*sx*sw));
X *p = atan(((sx*ceps)+(ty*seps*sw))/cx);
X if (cx<0) *p += PI; /* account for atan quad ambiguity */
X range (p, 2*PI);
X}
END_OF_FILE
if test 1899 -ne `wc -c <'eq_ecl.c'`; then
echo shar: \"'eq_ecl.c'\" unpacked with wrong size!
fi
# end of 'eq_ecl.c'
fi
if test -f 'man.a.hdr' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'man.a.hdr'\"
else
echo shar: Extracting \"'man.a.hdr'\" \(578 characters\)
sed "s/^X//" >'man.a.hdr' <<'END_OF_FILE'
XFrom e_downey@hwking.cca.cr.rockwell.com Tue Mar 10 11:56:34 1992
XReceived: from tasha.cca.cr.rockwell.com by sparky.IMD.Sterling.COM (5.65c/IDA-1.4.4)
X id AA15066; Tue, 10 Mar 1992 11:55:59 -0600
XReturn-Path: <e_downey@hwking.cca.cr.rockwell.com>
XReceived: by tasha.cca.cr.rockwell.com (5.57/Ultrix3.0-C)
X id AA27717; Tue, 10 Mar 92 11:54:19 -0600
XDate: Tue, 10 Mar 92 11:54:19 -0600
XFrom: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
XMessage-Id: <9203101754.AA27717@tasha.cca.cr.rockwell.com>
XTo: sources-misc@imd.sterling.com
XSubject: ephem, Man.a.shar
XStatus: OR
X
END_OF_FILE
if test 578 -ne `wc -c <'man.a.hdr'`; then
echo shar: \"'man.a.hdr'\" unpacked with wrong size!
fi
# end of 'man.a.hdr'
fi
if test -f 'man.b.hdr' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'man.b.hdr'\"
else
echo shar: Extracting \"'man.b.hdr'\" \(578 characters\)
sed "s/^X//" >'man.b.hdr' <<'END_OF_FILE'
XFrom e_downey@hwking.cca.cr.rockwell.com Tue Mar 10 11:56:31 1992
XReceived: from tasha.cca.cr.rockwell.com by sparky.IMD.Sterling.COM (5.65c/IDA-1.4.4)
X id AA15074; Tue, 10 Mar 1992 11:56:03 -0600
XReturn-Path: <e_downey@hwking.cca.cr.rockwell.com>
XReceived: by tasha.cca.cr.rockwell.com (5.57/Ultrix3.0-C)
X id AA27723; Tue, 10 Mar 92 11:54:26 -0600
XDate: Tue, 10 Mar 92 11:54:26 -0600
XFrom: e_downey@hwking.cca.cr.rockwell.com (Elwood C. Downey)
XMessage-Id: <9203101754.AA27723@tasha.cca.cr.rockwell.com>
XTo: sources-misc@imd.sterling.com
XSubject: ephem, Man.b.shar
XStatus: OR
X
END_OF_FILE
if test 578 -ne `wc -c <'man.b.hdr'`; then
echo shar: \"'man.b.hdr'\" unpacked with wrong size!
fi
# end of 'man.b.hdr'
fi
if test -f 'moonnf.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'moonnf.c'\"
else
echo shar: Extracting \"'moonnf.c'\" \(1557 characters\)
sed "s/^X//" >'moonnf.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <math.h>
X#include "astro.h"
X
X#define unw(w,z) ((w)-floor((w)/(z))*(z))
X
X/* given a modified Julian date, mjd, return the mjd of the new
X * and full moons about then, mjdn and mjdf.
X * TODO: exactly which ones does it find? eg:
X * 5/28/1988 yields 5/15 and 5/31
X * 5/29 6/14 6/29
X */
Xmoonnf (mjd, mjdn, mjdf)
Xdouble mjd;
Xdouble *mjdn, *mjdf;
X{
X int mo, yr;
X double dy;
X double mjd0;
X double k, tn, tf, t;
X
X mjd_cal (mjd, &mo, &dy, &yr);
X cal_mjd (1, 0., yr, &mjd0);
X k = (yr-1900+((mjd-mjd0)/365))*12.3685;
X k = floor(k+0.5);
X tn = k/1236.85;
X tf = (k+0.5)/1236.85;
X t = tn;
X m (t, k, mjdn);
X t = tf;
X k += 0.5;
X m (t, k, mjdf);
X}
X
Xstatic
Xm (t, k, mjd)
Xdouble t, k;
Xdouble *mjd;
X{
X double t2, a, a1, b, b1, c, ms, mm, f, ddjd;
X
X t2 = t*t;
X a = 29.53*k;
X c = degrad(166.56+(132.87-9.173e-3*t)*t);
X b = 5.8868e-4*k+(1.178e-4-1.55e-7*t)*t2+3.3e-4*sin(c)+7.5933E-1;
X ms = 359.2242+360*unw(k/1.236886e1,1)-(3.33e-5+3.47e-6*t)*t2;
X mm = 306.0253+360*unw(k/9.330851e-1,1)+(1.07306e-2+1.236e-5*t)*t2;
X f = 21.2964+360*unw(k/9.214926e-1,1)-(1.6528e-3+2.39e-6*t)*t2;
X ms = unw(ms,360);
X mm = unw(mm,360);
X f = unw(f,360);
X ms = degrad(ms);
X mm = degrad(mm);
X f = degrad(f);
X ddjd = (1.734e-1-3.93e-4*t)*sin(ms)+2.1e-3*sin(2*ms)
X -4.068e-1*sin(mm)+1.61e-2*sin(2*mm)-4e-4*sin(3*mm)
X +1.04e-2*sin(2*f)-5.1e-3*sin(ms+mm)-7.4e-3*sin(ms-mm)
X +4e-4*sin(2*f+ms)-4e-4*sin(2*f-ms)-6e-4*sin(2*f+mm)
X +1e-3*sin(2*f-mm)+5e-4*sin(ms+2*mm);
X a1 = (long)a;
X b = b+ddjd+(a-a1);
X b1 = (long)b;
X a = a1+b1;
X b = b-b1;
X *mjd = a + b;
X}
END_OF_FILE
if test 1557 -ne `wc -c <'moonnf.c'`; then
echo shar: \"'moonnf.c'\" unpacked with wrong size!
fi
# end of 'moonnf.c'
fi
if test -f 'obliq.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'obliq.c'\"
else
echo shar: Extracting \"'obliq.c'\" \(421 characters\)
sed "s/^X//" >'obliq.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include "astro.h"
X
X/* given the modified Julian date, mjd, find the obliquity of the
X * ecliptic, *eps, in radians.
X */
Xobliquity (mjd, eps)
Xdouble mjd;
Xdouble *eps;
X{
X static double lastmjd = -10000, lasteps;
X
X if (mjd != lastmjd) {
X double t;
X t = mjd/36525.;
X lasteps = degrad(2.345229444E1
X - ((((-1.81E-3*t)+5.9E-3)*t+4.6845E1)*t)/3600.0);
X lastmjd = mjd;
X }
X *eps = lasteps;
X}
END_OF_FILE
if test 421 -ne `wc -c <'obliq.c'`; then
echo shar: \"'obliq.c'\" unpacked with wrong size!
fi
# end of 'obliq.c'
fi
if test -f 'parallax.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'parallax.c'\"
else
echo shar: Extracting \"'parallax.c'\" \(2301 characters\)
sed "s/^X//" >'parallax.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <math.h>
X#include "astro.h"
X
X/* given true ha and dec, tha and tdec, the geographical latitude, phi, the
X * height above sea-level (as a fraction of the earths radius, 6378.16km),
X * ht, and the equatorial horizontal parallax, ehp, find the apparent
X * ha and dec, aha and adec allowing for parallax.
X * all angles in radians. ehp is the angle subtended at the body by the
X * earth's equator.
X */
Xta_par (tha, tdec, phi, ht, ehp, aha, adec)
Xdouble tha, tdec, phi, ht, ehp;
Xdouble *aha, *adec;
X{
X static double last_phi, last_ht, rsp, rcp;
X double rp; /* distance to object in Earth radii */
X double ctha;
X double stdec, ctdec;
X double tdtha, dtha;
X double caha;
X
X /* avoid calcs involving the same phi and ht */
X if (phi != last_phi || ht != last_ht) {
X double cphi, sphi, u;
X cphi = cos(phi);
X sphi = sin(phi);
X u = atan(9.96647e-1*sphi/cphi);
X rsp = (9.96647e-1*sin(u))+(ht*sphi);
X rcp = cos(u)+(ht*cphi);
X last_phi = phi;
X last_ht = ht;
X }
X
X rp = 1/sin(ehp);
X
X ctha = cos(tha);
X stdec = sin(tdec);
X ctdec = cos(tdec);
X tdtha = (rcp*sin(tha))/((rp*ctdec)-(rcp*ctha));
X dtha = atan(tdtha);
X *aha = tha+dtha;
X caha = cos(*aha);
X range (aha, 2*PI);
X *adec = atan(caha*(rp*stdec-rsp)/(rp*ctdec*ctha-rcp));
X}
X
X#ifdef NEEDIT
X/* given the apparent ha and dec, aha and adec, the geographical latitude, phi,
X * the height above sea-level (as a fraction of the earths radius, 6378.16km),
X * ht, and the equatorial horizontal parallax, ehp, find the true ha and dec,
X * tha and tdec allowing for parallax.
X * all angles in radians. ehp is the angle subtended at the body by the
X * earth's equator.
X * uses ta_par() iteratively: find a set of true ha/dec that converts back
X * to the given apparent ha/dec.
X */
Xat_par (aha, adec, phi, ht, ehp, tha, tdec)
Xdouble aha, adec, phi, ht, ehp;
Xdouble *tha, *tdec;
X{
X double nha, ndec; /* ha/dec corres. to current true guesses */
X double eha, edec; /* error in ha/dec */
X
X /* first guess for true is just the apparent */
X *tha = aha;
X *tdec = adec;
X
X while (1) {
X ta_par (*tha, *tdec, phi, ht, ehp, &nha, &ndec);
X eha = aha - nha;
X edec = adec - ndec;
X if (fabs(eha)<1e-6 && fabs(edec)<1e-6)
X break;
X *tha += eha;
X *tdec += edec;
X }
X}
X#endif
END_OF_FILE
if test 2301 -ne `wc -c <'parallax.c'`; then
echo shar: \"'parallax.c'\" unpacked with wrong size!
fi
# end of 'parallax.c'
fi
if test -f 'popup.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'popup.c'\"
else
echo shar: Extracting \"'popup.c'\" \(1734 characters\)
sed "s/^X//" >'popup.c' <<'END_OF_FILE'
X/* put up a one-line menu consisting of the given fields and let op move
X * between them with the same methods as sel_fld().
X * return index of which he picked, or -1 if hit END.
X */
X
X#include <stdio.h>
X#include "screen.h"
X
Xextern void bye();
X
X#define FLDGAP 2 /* inter-field gap */
X#define MAXFLDS 32 /* max number of fields we can handle */
X
Xstatic char pup[] = "Select: ";
X
X/* put up an array of strings on prompt line and let op pick one.
X * start with field fn.
X * N.B. we do not do much error/bounds checking.
X */
Xpopup (fields, fn, nfields)
Xchar *fields[];
Xint fn;
Xint nfields;
X{
X int fcols[MAXFLDS]; /* column to use for each field */
X int i;
X
X if (nfields > MAXFLDS)
X return (-1);
X
X again:
X /* erase the prompt line; we are going to take it over */
X c_pos (R_PROMPT, C_PROMPT);
X c_eol();
X
X /* compute starting column for each field */
X fcols[0] = sizeof(pup);
X for (i = 1; i < nfields; i++)
X fcols[i] = fcols[i-1] + strlen (fields[i-1]) + FLDGAP;
X
X /* draw each field, with comma after all but last */
X c_pos (R_PROMPT, 1);
X (void) fputs (pup, stdout);
X for (i = 0; i < nfields; i++) {
X c_pos (R_PROMPT, fcols[i]);
X printf (i < nfields-1 ? "%s," : "%s", fields[i]);
X }
X
X /* let op choose one now; begin at fn.
X */
X while (1) {
X c_pos (R_PROMPT, fcols[fn]);
X switch (read_char()) {
X case END: return (-1);
X case QUIT:
X f_prompt ("Exit ephem? (y) ");
X if (read_char() == 'y')
X bye(); /* never returns */
X goto again;
X case REDRAW: redraw_screen(2); goto again;
X case VERSION: version(); goto again;
X case '\r': case ' ': return (fn);
X case 'h':
X if (--fn < 0)
X fn = nfields - 1;
X break;
X case 'l':
X if (++fn >= nfields)
X fn = 0;
X break;
X }
X }
X}
END_OF_FILE
if test 1734 -ne `wc -c <'popup.c'`; then
echo shar: \"'popup.c'\" unpacked with wrong size!
fi
# end of 'popup.c'
fi
if test -f 'reduce.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'reduce.c'\"
else
echo shar: Extracting \"'reduce.c'\" \(1691 characters\)
sed "s/^X//" >'reduce.c' <<'END_OF_FILE'
X#include <math.h>
X#include "astro.h"
X
X/* convert those orbital elements that change from epoch mjd0 to epoch mjd.
X */
Xreduce_elements (mjd0, mjd, inc0, ap0, om0, inc, ap, om)
Xdouble mjd0; /* initial epoch */
Xdouble mjd; /* desired epoch */
Xdouble inc0; /* initial inclination, rads */
Xdouble ap0; /* initial argument of perihelion, as an mjd */
Xdouble om0; /* initial long of ascending node, rads */
Xdouble *inc; /* desired inclination, rads */
Xdouble *ap; /* desired epoch of perihelion, as an mjd */
Xdouble *om; /* desired long of ascending node, rads */
X{
X double t0, t1;
X double tt, tt2, t02, tt3;
X double eta, th, th0;
X double a, b;
X double dap;
X double cinc, sinc;
X double ot, sot, cot, ot1;
X double seta, ceta;
X
X t0 = mjd0/365250.0;
X t1 = mjd/365250.0;
X
X tt = t1-t0;
X tt2 = tt*tt;
X t02 = t0*t0;
X tt3 = tt*tt2;
X eta = (471.07-6.75*t0+.57*t02)*tt+(.57*t0-3.37)*tt2+.05*tt3;
X th0 = 32869.0*t0+56*t02-(8694+55*t0)*tt+3*tt2;
X eta = degrad(eta/3600.0);
X th0 = degrad((th0/3600.0)+173.950833);
X th = (50256.41+222.29*t0+.26*t02)*tt+(111.15+.26*t0)*tt2+.1*tt3;
X th = th0+degrad(th/3600.0);
X cinc = cos(inc0);
X sinc = sin(inc0);
X ot = om0-th0;
X sot = sin(ot);
X cot = cos(ot);
X seta = sin(eta);
X ceta = cos(eta);
X a = sinc*sot;
X b = ceta*sinc*cot-seta*cinc;
X ot1 = atan(a/b);
X if (b<0) ot1 += PI;
X b = sinc*ceta-cinc*seta*cot;
X a = -1*seta*sot;
X dap = atan(a/b);
X if (b<0) dap += PI;
X
X *ap = ap0+dap;
X range (ap, 2*PI);
X *om = ot1+th;
X range (om, 2*PI);
X
X if (inc0<.175)
X *inc = asin(a/sin(dap));
X else
X *inc = 1.570796327-asin((cinc*ceta)+(sinc*seta*cot));
X}
END_OF_FILE
if test 1691 -ne `wc -c <'reduce.c'`; then
echo shar: \"'reduce.c'\" unpacked with wrong size!
fi
# end of 'reduce.c'
fi
if test -f 'sex_dec.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'sex_dec.c'\"
else
echo shar: Extracting \"'sex_dec.c'\" \(1183 characters\)
sed "s/^X//" >'sex_dec.c' <<'END_OF_FILE'
X#include <math.h>
X
X/* given hours (or degrees), hd, minutes, m, and seconds, s,
X * return decimal hours (or degrees), *d.
X * in the case of hours (angles) < 0, only the first non-zero element should
X * be negative.
X */
Xsex_dec (hd, m, s, d)
Xint hd, m, s;
Xdouble *d;
X{
X int sign = 1;
X
X if (hd < 0) {
X sign = -1;
X hd = -hd;
X } else if (m < 0) {
X sign = -1;
X m = -m;
X } else if (s < 0) {
X sign = -1;
X s = -s;
X }
X
X *d = (((double)s/60.0 + (double)m)/60.0 + (double)hd) * sign;
X}
X
X/* given decimal hours (or degrees), d.
X * return nearest hours (or degrees), *hd, minutes, *m, and seconds, *s,
X * each always non-negative; *isneg is set to 1 if d is < 0, else to 0.
X */
Xdec_sex (d, hd, m, s, isneg)
Xdouble d;
Xint *hd, *m, *s, *isneg;
X{
X double min;
X
X if (d < 0) {
X *isneg = 1;
X d = -d;
X } else
X *isneg = 0;
X
X *hd = (int)d;
X min = (d - *hd)*60.;
X *m = (int)min;
X *s = (int)((min - *m)*60. + 0.5);
X
X if (*s == 60) {
X if ((*m += 1) == 60) {
X *hd += 1;
X *m = 0;
X }
X *s = 0;
X }
X /* no negative 0's */
X if (*hd == 0 && *m == 0 && *s == 0)
X *isneg = 0;
X}
X
X/* insure 0 <= *v < r.
X */
Xrange (v, r)
Xdouble *v, r;
X{
X *v -= r*floor(*v/r);
X}
END_OF_FILE
if test 1183 -ne `wc -c <'sex_dec.c'`; then
echo shar: \"'sex_dec.c'\" unpacked with wrong size!
fi
# end of 'sex_dec.c'
fi
if test -f 'sun.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'sun.c'\"
else
echo shar: Extracting \"'sun.c'\" \(1760 characters\)
sed "s/^X//" >'sun.c' <<'END_OF_FILE'
X#include <stdio.h>
X#include <math.h>
X#include "astro.h"
X
X/* given the modified JD, mjd, return the true geocentric ecliptic longitude
X * of the sun for the mean equinox of the date, *lsn, in radians, and the
X * sun-earth distance, *rsn, in AU. (the true ecliptic latitude is never more
X * than 1.2 arc seconds and so may be taken to be a constant 0.)
X * if the APPARENT ecliptic longitude is required, correct the longitude for
X * nutation to the true equinox of date and for aberration (light travel time,
X * approximately -9.27e7/186000/(3600*24*365)*2*pi = -9.93e-5 radians).
X */
Xsunpos (mjd, lsn, rsn)
Xdouble mjd;
Xdouble *lsn, *rsn;
X{
X double t, t2;
X double ls, ms; /* mean longitude and mean anomoay */
X double s, nu, ea; /* eccentricity, true anomaly, eccentric anomaly */
X double a, b, a1, b1, c1, d1, e1, h1, dl, dr;
X
X t = mjd/36525.;
X t2 = t*t;
X a = 100.0021359*t;
X b = 360.*(a-(long)a);
X ls = 279.69668+.0003025*t2+b;
X a = 99.99736042000039*t;
X b = 360*(a-(long)a);
X ms = 358.47583-(.00015+.0000033*t)*t2+b;
X s = .016751-.0000418*t-1.26e-07*t2;
X anomaly (degrad(ms), s, &nu, &ea);
X a = 62.55209472000015*t;
X b = 360*(a-(long)a);
X a1 = degrad(153.23+b);
X a = 125.1041894*t;
X b = 360*(a-(long)a);
X b1 = degrad(216.57+b);
X a = 91.56766028*t;
X b = 360*(a-(long)a);
X c1 = degrad(312.69+b);
X a = 1236.853095*t;
X b = 360*(a-(long)a);
X d1 = degrad(350.74-.00144*t2+b);
X e1 = degrad(231.19+20.2*t);
X a = 183.1353208*t;
X b = 360*(a-(long)a);
X h1 = degrad(353.4+b);
X dl = .00134*cos(a1)+.00154*cos(b1)+.002*cos(c1)+.00179*sin(d1)+
X .00178*sin(e1);
X dr = 5.43e-06*sin(a1)+1.575e-05*sin(b1)+1.627e-05*sin(c1)+
X 3.076e-05*cos(d1)+9.27e-06*sin(h1);
X *lsn = nu+degrad(ls-ms+dl);
X *rsn = 1.0000002*(1-s*cos(ea))+dr;
X range (lsn, 2*PI);
X}
END_OF_FILE
if test 1760 -ne `wc -c <'sun.c'`; then
echo shar: \"'sun.c'\" unpacked with wrong size!
fi
# end of 'sun.c'
fi
if test -f 'utc_gst.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'utc_gst.c'\"
else
echo shar: Extracting \"'utc_gst.c'\" \(1189 characters\)
sed "s/^X//" >'utc_gst.c' <<'END_OF_FILE'
X#include "astro.h"
X
X/* given a modified julian date, mjd, and a universally coordinated time, utc,
X * return greenwich mean siderial time, *gst.
X */
Xutc_gst (mjd, utc, gst)
Xdouble mjd;
Xdouble utc;
Xdouble *gst;
X{
X double tnaught();
X static double lastmjd = -10000;
X static double t0;
X
X if (mjd != lastmjd) {
X t0 = tnaught (mjd);
X lastmjd = mjd;
X }
X *gst = (1.0/SIDRATE)*utc + t0;
X range (gst, 24.0);
X}
X
X/* given a modified julian date, mjd, and a greenwich mean siderial time, gst,
X * return universally coordinated time, *utc.
X */
Xgst_utc (mjd, gst, utc)
Xdouble mjd;
Xdouble gst;
Xdouble *utc;
X{
X double tnaught();
X static double lastmjd = -10000;
X static double t0;
X
X if (mjd != lastmjd) {
X t0 = tnaught (mjd);
X range (&t0, 24.0);
X lastmjd = mjd;
X }
X *utc = gst - t0;
X range (utc, 24.0);
X *utc *= SIDRATE;
X}
X
Xstatic double
Xtnaught (mjd)
Xdouble mjd; /* julian days since 1900 jan 0.5 */
X{
X double dmjd;
X int m, y;
X double d;
X double t, t0;
X
X mjd_cal (mjd, &m, &d, &y);
X cal_mjd (1, 0., y, &dmjd);
X t = dmjd/36525;
X t0 = 6.57098e-2 * (mjd - dmjd) -
X (24 - (6.6460656 + (5.1262e-2 + (t * 2.581e-5))*t) -
X (2400 * (t - (((double)y - 1900)/100))));
X return (t0);
X}
END_OF_FILE
if test 1189 -ne `wc -c <'utc_gst.c'`; then
echo shar: \"'utc_gst.c'\" unpacked with wrong size!
fi
# end of 'utc_gst.c'
fi
echo shar: End of archive 9 \(of 9\).
cp /dev/null ark9isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 9 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still must unpack the following archives:
echo " " ${MISSING}
fi
exit 0
exit 0 # Just in case...