home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Crawly Crypt Collection 2
/
crawlyvol2.bin
/
apps
/
science
/
norad
/
noradsc
/
norad.lst
next >
Wrap
File List
|
1990-06-06
|
35KB
|
1,078 lines
REM N.O.R.A.D. V2.0 The graphic realtime satellite tracking program.
REM ATARI ST -- GFA BASIC 3.07
REM Please customize the six lines below.
REM
tlocal=-5 ! Your time difference from GMT (UTC). i.e. -5 = CDT
l9=45.0709 ! Your latitude, degrees.fraction-of-degrees.
w9=93.1567 ! Your longitude, degrees.fraction. i.e +values for USA
h9=980 ! Your altitude above sea-level. (Feet)
el$="C:\orbitals.dat" ! Path to orbital elements file. (NASA Predictions)
ms=2000 ! Maximum number of satellites. (To reserve space)
REM
MODE 1 ! GFA Basic 3.07 compiler default override.
REM
REM Orbital calculation subroutines from the AMSAT Orbital Prediction Program
REM (C) 1980 by Dr. T. A. Clark W3IWI, 6388 Guilford Road, Clarksville MD
REM 21209 USA. "Permission granted for non-commercial use provided credit is
REM given to author, AMSAT and ORBIT magazine. See ORBIT issue 6, March/
REM April 1981. Ported to ATARI ST BASIC by Scott Tilley (1/24/87.)
REM
REM Graphic interface and world map by John Logajan, 4248 Hamline, Arden Hills
REM MN 55112 USA. 6/3/90 Graphic interface and map code are released into
REM the public domain. logajan@ns.network.com john@logajan.mn.org
REM
CLS
h9=h9*12/39.37 ! convert feet height to meters
REPEAT
REPEAT
DEFTEXT 3,0,0,32
TEXT 100,25,0,"Welcome to N.O.R.A.D. V2"
DEFTEXT 1,0,0,13
TEXT 105,45,0,"Your clock said the time was: "+DATE$+" "+TIME$
DEFTEXT 2,0,0,13
TEXT 100,61,0,"Please be sure it is set to the EXACT time and date!"
TEXT 175,152,0,"Press the HELP-key for instructions."
TEXT 220,170,0,"Press the ESC-key to exit."
TEXT 80,186,0,"- Point at satellite of interest and click to get its info -"
a$="Want to set/reset the clock?"
ALERT 2,a$,1,"No need|SetClock|Quit!",but
IF but=3
EDIT
ENDIF
IF but=2
CLS
PRINT "Enter date (or RETURN to skip)"
PRINT
PRINT "Use the format month/day/year."
PRINT "Be sure to use two digits (leading zeroes) for each."
PRINT "Otherwise the system will ignore the new date."
PRINT
PRINT DATE$;
INPUT " Date ";d$
CLS
PRINT "Enter local time (or RETURN to skip)"
PRINT
PRINT "Use the format hour:minute:second."
PRINT "Be sure to use two digits (leading zeroes) for each."
PRINT "Otherwise the system will ignore the new time."
PRINT
PRINT TIME$;
INPUT " Time ";t$
SETTIME t$,d$
ENDIF
CLS
UNTIL but=1
y=VAL(RIGHT$(DATE$,4))-1900
IF y<89
PRINT " Is it really the year ";1900+y;" ?"
PRINT "I haven't made the program so it can work in years before 1989,"
PRINT "so I am going to force you to set your clock/calender."
ALERT 1," ",1,"continue",but
CLS
ENDIF
UNTIL y>=89
IF y/4=INT(y/4)
f9=1
ELSE
f9=0 ! leap-year flag
ENDIF
d=VAL(MID$(DATE$,4,2))
m=VAL(LEFT$(DATE$,2))
REM Calculate day of year
DATA 0,31,59,90,120,151,181,212,243,273,304,334
FOR i=1 TO 12
READ d9x
IF i=m
d9=d9x
ENDIF
NEXT i
d8=d+d9
IF m>2
d8=d8+f9
ENDIF
t$=TIME$
tstart=TIMER
h=VAL(LEFT$(t$,2))
s=VAL(RIGHT$(t$,2))
m=VAL(MID$(t$,4,2))
t7=d8+h/24+m/1440+s/86400-tlocal/24
leapy=30/60/60/24
r0=6378.135 ! earth mean diameter km
f=298.25 ! delta diameter km
f=1/f
g0=75369793000000 ! gravitational constant
g1=1.0027379093 ! sidereal/solar ratio
p2=2*PI
p0=PI/180
pd2=PI/2
pday=p2/365.2422 ! 2*pi/days per year
seg=279.04247*p0 ! sun's ecliptic longitude at 1975
swg=282.510396*p0 ! sun's ecliptic longitude at perigee
see=0.01672*2 ! eccentricy of earth orbit
sepoch=5114 ! days between 1975 and 1989 (my base year)
obliq=23.4333333*p0 ! obliquity of the ecliptic
cobliq=COS(obliq)
sobliq=SIN(obliq)
cl9p0=COS(l9*p0)
sl9p0=SIN(l9*p0)
dseg=seg-swg
ltsun=0
w9x=w9/15
REM Greenwich Sidereal Time at New Year's
yt%=0
FOR y1=90 TO y
yd%=365
IF y1/4=INT(y1/4)
yd%=366
ENDIF
yt%=yt%+yd%
NEXT y1
g2=FRAC(yt%*g1+0.27676779) ! Figure forward from 0.0.1989 GMT
sepoch=sepoch+yt%
REM Routine to evaluate OBSERVER's GEOCENTRIC Coordinates, where
REM X-axis=GREENWICH, Y-axis goes thru India, Z-axis=North Pole
l8=l9*p0
s9=SIN(l8)
c9=COS(l8) ! Initial GEOCENTRIC coordinates
s8=SIN(-w9*p0)
c8=COS(w9*p0) ! W9= West longitude
REM Now to account for flattened Earth
r9=r0*(1-(f/2)+(f/2)*COS(2*l8))+h9/1000 ! H9=height in meters
REM Now to make L8 the GEOCENTRIC latitude
l8=ATN((1-f)^2*s9/c9)
z9=r9*SIN(l8)
x9=r9*COS(l8)*c8
y9=r9*COS(l8)*s8
REM *********** get Parameters for Satellites *********
PRINT "Reading orbital elements from file: ";el$
PRINT
ON ERROR GOSUB missing
OPEN "I",#1,el$
msx%=LOF(#1)/141
IF msx%<ms
ms=msx%
ENDIF
DIM c(3,2),lvt%(200),s$(ms),y3(ms),t0(ms),mmr(ms),i0(ms),o0(ms),e0(ms)
DIM w0(ms),m0(ms),n0(ms),k0(ms),a0(ms),xx%(ms),yy%(ms),e(ms),prob|(ms)
sp%=0
ON ERROR GOSUB baddy
DO
EXIT IF EOF(#1)
LINE INPUT #1,ln$
EXIT IF EOF(#1)
LINE INPUT #1,l1$
EXIT IF EOF(#1)
LINE INPUT #1,l2$
WHILE LEFT$(l1$,1)<>"1" OR LEFT$(l2$,1)<>"2"
ln$=l1$
l1$=l2$
EXIT IF EOF(#1)
LINE INPUT #1,l2$
WEND
INC sp%
s$(sp%)="[ ]"
MID$(s$(sp%),2,14)=LEFT$(ln$,14)
MID$(s$(sp%),17,5)=MID$(l1$,3,5)
y3(sp%)=VAL(MID$(l1$,19,2))
t0(sp%)=VAL(MID$(l1$,21,12))
IF y3(sp%)<y ! Correct for "old" orbital elements
yt%=0
FOR y1=y3(sp%) TO y-1
yd%=365
IF y1/4=INT(y1/4)
yd%=366
ENDIF
yt%=yt%+yd%
NEXT y1
t0(sp%)=t0(sp%)-yt%
y3(sp%)=y
ENDIF
mmr(sp%)=VAL(MID$(l1$,34,10))
i0(sp%)=VAL(MID$(l2$,9,8))
o0(sp%)=VAL(MID$(l2$,18,8))
e0(sp%)=VAL("."+MID$(l2$,27,7))
w0(sp%)=VAL(MID$(l2$,35,8))
m0(sp%)=VAL(MID$(l2$,44,8))
n0(sp%)=VAL(MID$(l2$,53,11))
k0(sp%)=VAL(MID$(l2$,64,5))
a0(sp%)=((g0/(n0(sp%)^2))^(1/3))
e(sp%)=0
PRINT sp%;TAB(5);s$(sp%)
IF sp%=ms
PRINT "Oops! Not enough room reserved for all satellite elements."
PRINT "Increase the variable -Ms- to a higher number and try again."
EDIT
ENDIF
IF INP?(2)
IF INP(2)=27
EDIT
ENDIF
ENDIF
LOOP
ON ERROR
IF sp%=0
GOSUB missing
ENDIF
CLOSE #1
mxsp%=sp%-1
mxsps%=sp%
FOR i%=1 TO mxsp%
prob|(i%)=0
NEXT i%
nowreck!=FALSE
IF FRE(0)>50000
nowreck!=TRUE
DIM helparray%(33000/4)
helpstuff%=INT(VARPTR(helparray%(0))/256)*256+256
keepalive%=XBIOS(2)
ENDIF
REM ******** Here follows the actual computation loop *********
CLS
SETCOLOR 0,0,0,0 ! For color 0 (black -- background)
SETCOLOR 1,0,0,7 ! For color 2 (blue -- trails)
SETCOLOR 3,7,0,0 ! For color 1 (red -- satellites/text/arrow)
SETCOLOR 2,3,2,0 ! For color 3 (brown -- world map)
DEFMOUSE 0
DEFFILL 3,1
white!=FALSE
hilite!=FALSE
facts!=FALSE
clkon!=FALSE
clkfast!=FALSE
mapon!=TRUE
equat!=FALSE
helpme!=FALSE
lookup!=FALSE
found!=FALSE
sunfacts!=FALSE
sunchk!=FALSE
radaron!=FALSE
leaptime!=FALSE
vpage%=0
d$=CHR$(248)
GOSUB map
DO
GOSUB sun
IF sunfacts!
GOSUB factsun
ENDIF
FOR sp%=1 TO mxsp%
IF (NOT radaron!) OR (radaron! AND prob|(sp%)<1)
t=t7+(TIMER-tstart)/17280000
GOSUB fnc
COLOR 2
IF hilite!
IF sp%=sr%
COLOR 1
ENDIF
ENDIF
PLOT xx%(sp%),yy%(sp%)
COLOR 1
IF sunchk! AND ((NOT radaron!) OR (radaron! AND e9>0))
gcca=COS((sunlng-wx5-180)*p0)
gcsatc=(90-l5)*p0
gcangle=(ACOS(gcbcos*COS(gcsatc)+gcbsin*SIN(gcsatc)*gcca))/p0
IF gcangle>90
shad=r*COS((gcangle-90)*p0)
IF shad<r0
COLOR 2
ENDIF
ENDIF
ENDIF
IF radaron!
IF e9=>0
rrr=90-e9
yy%(sp%)=100-rrr*COSQ(a9)
xx%(sp%)=2.4*rrr*SINQ(a9)+320
PLOT xx%(sp%),yy%(sp%)
ENDIF
ELSE
yy%(sp%)=1.11111111*(90-l5)
xx%(sp%)=1.77777777*(360-wx5)
PLOT xx%(sp%),yy%(sp%)
ENDIF
ELSE
DEC prob|(sp%)
ENDIF
IF facts!
SWAP sp%,sr%
t=t7+(TIMER-tstart)/17280000
IF leaptime!
t=t+leapy
ENDIF
GOSUB fnc
LOCATE 1,1
PRINT USING "&###!"," AZ=",a9,d$;
LOCATE 9,1
PRINT USING "&-##!"," EL=",e9,d$;
IF NOT equat!
LOCATE 17,1
PRINT USING "&######!"," ALT=",(r-r0)*0.6215,"m";
LOCATE 29,1
PRINT USING "&-##!"," LT=",l5,d$;
LOCATE 37,1
PRINT USING "&-###!"," LN=",wx5-180,d$;
ELSE
REM Local horizon to Equatorial
sdec=ASIN(SIN(e9*p0)*sl9p0+COS(e9*p0)*cl9p0*COS(a9*p0))
sha=ACOS((SIN(e9*p0)-sl9p0*SIN(sdec))/cl9p0/COS(sdec))
IF SIN(a9*p0)>0
sha=p2-sha
ENDIF
sha=sha/15/p0/24
sra=FRAC(t*g1+g2-w9/360-sha)*24
ram=FRAC(sra)*60
ras=FRAC(ram)*60
sdec=sdec/p0
decm=FRAC(ABS(sdec))*60
decs=FRAC(decm)*60
LOCATE 17,1
PRINT USING "&##!##!##!"," RA=",INT(sra),"h",INT(ram),"m",ras,"s";
LOCATE 30,1
PRINT USING "&-##!##!##!"," DEC=",INT(sdec),d$,INT(decm),"'",decs,"""";
ENDIF
LOCATE 46,1
PRINT USING "&#####"," ORB#=",k;
LOCATE 58,1
IF leaptime!
PRINT ">< 30 Seconds Fast! ><";
ELSE
PRINT s$(sp%);
ENDIF
SWAP sp%,sr%
ENDIF
IF MOUSEK<>0 AND NOT lookup!
xm%=MOUSEX
ym%=MOUSEY
hilite!=FALSE
facts!=FALSE
sunfacts!=FALSE
PAUSE 1
mk%=MOUSEK
LOCATE 1,1
PRINT SPC(79);
found!=FALSE
FOR sr%=0 TO mxsps%
IF ((xx%(sr%)-xm%) AND &HFFE)=0 AND ((yy%(sr%)-ym%) AND &HFFE)=0
found!=TRUE
PRINT CHR$(7); ! Sound bell!
PAUSE 50
ENDIF
EXIT IF found!
NEXT sr%
IF sr%=0
found!=FALSE
LOCATE 1,1
PRINT "[ YOUR Location ] ";l9;d$'"Lat."'''w9;d$'"Long.";
ENDIF
IF sr%=mxsps%
found!=FALSE
sunfacts!=TRUE
GOSUB factsun
ENDIF
IF mk%=1 OR mk%=3
facts!=found!
ENDIF
IF mk%=2 OR mk%=3
hilite!=found!
ENDIF
found!=FALSE
ENDIF
IF INP?(2) OR found!=TRUE
IF found!=FALSE
ex$=INKEY$
ELSE
ex$="bleck"
ENDIF
IF helpme!=TRUE OR lookup!=TRUE AND ex$<>CHR$(0)+"H" AND ex$<>CHR$(0)+"P"
IF nowreck!
~XBIOS(5,L:keepalive%,L:keepalive%,-1)
VSYNC
VSYNC
ELSE
GOSUB map
ENDIF
helpme!=FALSE
lookup!=FALSE
IF found!
LOCATE 1,1
PRINT SPC(79);
found!=FALSE
ENDIF
vpage%=0
ex$="bleck"
ENDIF
IF ex$=CHR$(27) ! Esc key quits.
alt$="Really Quit?"
ALERT 3,alt$,1,"Quit!|Stay",but
IF but=1
GOSUB done
ENDIF
ENDIF
IF ex$=CHR$(0)+"b" ! Help key
GOSUB help
ENDIF
IF ex$=CHR$(0)+"G" ! Clr/Home key clears screen
GOSUB map
ENDIF
IF ex$=CHR$(0)+";" ! F1 - toggel background
white!=NOT white!
IF white!
SETCOLOR 0,7,7,7
SETCOLOR 1,0,0,0
SETCOLOR 2,5,6,3
ELSE
SETCOLOR 0,0,0,0
SETCOLOR 1,0,0,7
SETCOLOR 3,7,0,0
SETCOLOR 2,3,2,0
ENDIF
ENDIF
IF ex$=CHR$(0)+"<" ! F2 - toggel world map drawing
mapon!=NOT mapon!
IF mapon!
LOCATE 1,1
PRINT "Map/Grid OFF at next CLR/HOME ";
ELSE
LOCATE 1,1
PRINT "Map/Grid ON at next CLR/HOME ";
ENDIF
PAUSE 50
LOCATE 1,1
PRINT SPC(35);
ENDIF
IF ex$=CHR$(0)+"=" ! F3 - toggel clock
clkon!=NOT clkon!
clkfast!=FALSE
IF NOT clkon!
sf=8
LOCATE sf,25
PRINT SPC(64);
IF mapon! AND NOT radaron!
FILL 200,198
ENDIF
ELSE
sf=8
LOCATE sf,25
GOSUB disclk
ENDIF
ENDIF
IF ex$=CHR$(0)+">" ! F4 - toggel fast clock
clkfast!=NOT clkfast!
clkon!=FALSE
IF NOT clkfast!
sf=8
LOCATE sf,25
PRINT SPC(64);
IF mapon! AND NOT radaron!
FILL 200,198
ENDIF
ELSE
sf=8
LOCATE sf,25
GOSUB disclk
ENDIF
ENDIF
IF ex$=CHR$(0)+"?" AND facts! ! F5 - toggel equatorial/horizon
equat!=NOT equat!
LOCATE 17,1
PRINT SPC(30);
ENDIF
IF ex$=CHR$(0)+"@" ! F6 - Toggel sunshine check
sunchk!=NOT sunchk!
ENDIF
IF ex$=CHR$(0)+"A" ! F7 - Toggel RADAR screen / world view.
radaron!=NOT radaron!
GOSUB map
ENDIF
IF ex$=CHR$(0)+"B" AND facts! ! F8 - Toggel Leap-Ahead 30 seconds.
leaptime!=NOT leaptime!
ENDIF
IF ex$=CHR$(0)+"P" AND lookup! ! Directory page up.
vpage%=vpage%+110
IF vpage%>mxsp%
vpage%=vpage%-110
IF vpage%<0
vpage%=0
ENDIF
ENDIF
ex$=CHR$(0)+"R"
ENDIF
IF ex$=CHR$(0)+"H" AND lookup! ! Directory page down.
vpage%=vpage%-110
IF vpage%<0
vpage%=0
ENDIF
ex$=CHR$(0)+"R"
ENDIF
IF ex$=CHR$(0)+"R" ! INSERT - List and select from catalog
IF nowreck!
~XBIOS(5,L:helpstuff%,L:helpstuff%,-1)
VSYNC
VSYNC
CLS
ENDIF
LOCATE 1,2
vv%=vpage%
vvv%=0
REPEAT
INC vvv%
INC vv%
PRINT MID$(s$(vv%),2,14)';
IF (vv% MOD 5)=0
PRINT
ENDIF
UNTIL vv%=mxsp% OR vvv%=110
LOCATE 31,24
PRINT "*** Use arrow keys to page up/down ***"
IF nowreck!
~XBIOS(5,L:keepalive%,L:helpstuff%,-1)
ENDIF
lookup!=TRUE
found!=FALSE
ENDIF
ENDIF
IF clkfast!
sf=8
LOCATE sf,25
GOSUB disclk
ENDIF
IF lookup!
IF nowreck!
~XBIOS(5,L:helpstuff%,L:helpstuff%,-1)
VSYNC
VSYNC
ENDIF
xm%=MOUSEX
ym%=MOUSEY
IF ym%>7 AND ym%<184
srx%=vpage%+INT((ym%-8)/8)*5+INT(xm%/120)+1
IF srx%>mxsp%
srx%=mxsp%
ENDIF
IF srx%<0
srx%=1
ENDIF
ENDIF
IF MOUSEK<>0
PAUSE 1
mk%=MOUSEK
PRINT CHR$(7);
PAUSE 50
facts!=FALSE
hilite!=FALSE
sr%=srx%
IF mk%=1 OR mk%=3
facts!=TRUE
ENDIF
IF mk%=2 OR mk%=3
hilite!=TRUE
ENDIF
found!=TRUE
ENDIF
LOCATE 3,24
PRINT s$(srx%);
IF nowreck!
~XBIOS(5,L:keepalive%,L:helpstuff%,-1)
ENDIF
ENDIF
NEXT sp%
IF clkon!
sf=8
LOCATE sf,25
GOSUB disclk
ENDIF
LOOP
END
PROCEDURE missing
PRINT "The data file is missing or empty! You need the orbital elements"
PRINT "data for each satellite -- available on-line from the Celestial BBS,"
PRINT " @ 513-427-0674, Fairborn Ohio, TS Kelso -- sysop."
PRINT
PRINT "Or, if you have the file, make sure you change the path in the first"
PRINT "few lines of this program to point to it! Right now the path is set"
PRINT "to point at ";el$
STOP
RETURN
PROCEDURE baddy
PRINT "The data file ";el$;" has problems."
PRINT "The most likely problem is that the line at the end of the file is"
PRINT "not terminated by a carriage return (CR) and/or line feed (LF)."
PRINT "Please correct the file and try it again!"
STOP
RETURN
PROCEDURE done
COLOR 1
SETCOLOR 0,7,7,7
SETCOLOR 3,0,0,0
SETCOLOR 1,7,0,0
SETCOLOR 2,0,7,0
EDIT
RETURN
PROCEDURE factsun
LOCATE 1,1
PRINT "[ Sun, Sol, Helios ] ";
LOCATE 24,1
PRINT USING "-##.#####!&",decsun/p0,d$," Lat. ";
LOCATE 42,1
PRINT USING "-###.#####!&",sunlng,d$," Long. ";
RETURN
PROCEDURE help
IF nowreck!
~XBIOS(5,L:helpstuff%,L:helpstuff%,-1)
VSYNC
VSYNC
CLS
ENDIF
LOCATE 1,1
PRINT "Aim mouse-arrow (carefully) at satellite of interest and:"
PRINT " DATA - click LEFT mouse button to show data on that satellite."
PRINT " HILITE - click RIGHT mouse button to highlight (red) satellite trail."
PRINT " BOTH - click BOTH mouse buttons to show data and highlight trail."
PRINT
PRINT "ESC - Quit the program."
PRINT "Clr/Home - Erase screen."
PRINT "HELP (key) - Toggel help information on/off."
PRINT "ALT+HELP - Print screen (Hint: Toggel screen colors first (F1.))"
PRINT "INSERT - Select specific satellite from list."
PRINT "F1 - Toggel screen colors (useful for screen dumps.)"
PRINT "F2 - Toggel world map on/off (takes effect at next Clr/Home press.)"
PRINT "F3 - Slow update clocks (once per loop of all satellites.)"
PRINT "F4 - Fast update clocks (once per each satellite update.)"
PRINT "F5 - Toggel between LT/LN/ALT and RA/DEC in satellite data line."
PRINT "F6 - Show only satellites in sunshine (not in earth's shadow.)"
PRINT "F7 - Toggel between WORLD VIEW and LOCAL RADAR."
PRINT "F8 - Toggel Jump-Ahead 30 seconds (for Sat. data only.)"
PRINT
PRINT " AZ(imuth) 0=N 90=E 180=S 270=W / EL(evation) 0=Horizon, 90=Overhead."
PRINT " ALT(itude) Miles above average sea-level."
PRINT " LT/LN: Latitude(90=N, -90=S) / Longitude(180=W, 0=Greenwich, -180=E.)"
PRINT " ORB#: Current revolution #. / [ xx ] - Description and Satellite #."
PRINT " RA/DEC: Right Ascension (h m s) / Declination (d m s)."
PRINT " LT/LST/GMT/GST Local Solar/Sidereal - Greenwich Solar/Sidereal time.";
IF nowreck!
~XBIOS(5,L:keepalive%,L:helpstuff%,-1)
ENDIF
helpme!=TRUE
RETURN
REM ********** ORBIT DETERMINATION ROUTINES ******************
PROCEDURE fnc
REM Routine to initialize the C(J,K) coordinate rotation matrix
REM and other parameters associated with the orbital elements.
REM a0(sp%)=((g0/(n0(sp%)^2))^(1/3))
e2=1-e0(sp%)^2
e1=SQR(e2)
q0=m0(sp%)/360+k0(sp%) ! Q0=initial orbit phase
REM -----Account for nodal effects due to lumpy gravity field due to
REM the flattened, oblate spheroid shape of Earth
k2=9.95*((r0/a0(sp%))^3.5)/(e2^2)
REM Update elements to current epoch and evaluate their SIN/COSs
s1=SIN(i0(sp%)*p0)
c1=COS(i0(sp%)*p0) ! I0=inclination
k2=(t-t0(sp%))*k2
o=o0(sp%)-k2*c1
s0=SIN(o*p0)
c0=COS(o*p0) ! O = R.A.A.N. (deg)
w=w0(sp%)+k2*(2.5*(c1^2)-0.5)
s2=SIN(w*p0)
c2=COS(w*p0) ! W = arg of perigee
REM Set up coordinate rotation matrix for the current orbit
c(1,1)=+(c2*c0)-(s2*s0*c1)
c(1,2)=-(s2*c0)-(c2*s0*c1)
c(2,1)=+(c2*s0)+(s2*c0*c1)
c(2,2)=-(s2*s0)+(c2*c0*c1)
c(3,1)=+(s2*s1)
c(3,2)=+(c2*s1)
REM ---- Function to evaluate M = MEAN ANOMALY in 0-2pi range----
REM K = perigee passage counter
q=n0(sp%)*(t-t0(sp%))+q0
k=INT(q)
m=(q-k)*p2
REM Routine to solve KEPLER's equation, given M
REM returns satellite's GEOCENTRIC coordinates
IF e(sp%)=0
e(sp%)=m+e0(sp%)*SIN(m)+0.5*(e0(sp%)^2)*SIN(2*m) ! initial trial value
ENDIF
REM interation loop to solve Kepler's transcental equation-------
e=e(sp%)
DO
s3=SIN(e)
c3=COS(e)
r3=1-e0(sp%)*c3
m1=e-e0(sp%)*s3
m5=m1-m
EXIT IF ABS(m5)<1.0E-06
e=e-m5/r3
LOOP
e(sp%)=e
REM Now get satellite's XYZ coordinates------------
x0=a0(sp%)*(c3-e0(sp%))
y0=a0(sp%)*e1*s3
r=a0(sp%)*r3 ! in the plane of the orbit
REM Now rotate from orbital plane to INERTIAL CELESTIAL Coordinates
x1=x0*c(1,1)+y0*c(1,2)
y1=x0*c(2,1)+y0*c(2,2)
z1=x0*c(3,1)+y0*c(3,2)
REM Rotate through current GHA of Aries, convert to GEOCENTRIC coordinates
g7=FRAC(t*g1+g2)*p2
s7=-SIN(g7)
c7=COS(g7)
x=+(x1*c7)-(y1*s7)
y=+(x1*s7)+(y1*c7)
z=z1
REM Routine to extract all the parameters you might ever need
REM First get Vector from observer to satellite--
x5=(x-x9)
y5=(y-y9)
z5=(z-z9)
r5=SQR(x5^2+y5^2+z5^2)
REM Now rotate into observer' s LOCAL Coordinates----
REM where X8=North, Y8=East, Z8=Up (Left-handed system)
z8=+(x5*c8*c9)+(y5*s8*c9)+(z5*s9)
x8=-(x5*c8*s9)-(y5*s8*s9)+(z5*c9)
y8=+(y5*c8)-(x5*s8)
s5=z8/r5
c5=SQR(1-s5*s5)
e9=(ATN(s5/c5))/p0 ! E9=elevation
dx=x8
dy=y8
GOSUB fna
a9=d/p0 ! FNA resolves quadrant A9=Azimuth
dx=x
dy=y
GOSUB fna
w5=360-d/p0 ! W5=SubSatellitePoint W.long.
wx5=(w5+180) MOD 360
b5=z/r
l5=ATN(b5/(SQR(1-b5^2)))/p0 ! L5=SSP Lat.
prob|(sp%)=0
IF e9<0
prob|(sp%)=ABS(e9)
ENDIF
RETURN !---note R-R0=sat. alt. above mean spheroid
REM --------------------------------------------------------------------
PROCEDURE fna
REM Calculates INVERSE TANGENT in proper quadrant ala FORTRAN ATAN2
IF dx<0
d=PI+ATN(dy/dx) ! Q2 or Q3
ENDIF
IF dx>0 ! Q1 or Q4
IF dy>=0
d=ATN(dy/dx)
ELSE
d=p2+ATN(dy/dx)
ENDIF
ENDIF
REM The two cases for DX=0
IF dx=0
IF dy>=0
d=PI/2
ELSE
d=3*PI/2
ENDIF
ENDIF
RETURN
REM -------------------------------------------------------------------
PROCEDURE disclk
t=t7+(TIMER-tstart)/17280000
PRINT DATE$';
LOCATE sf+11,25
ft=FRAC(t+tlocal/24)*24
@prtime
PRINT " LT";
LOCATE sf+24,25
ft=FRAC(t)*24
@prtime
PRINT " GMT";
LOCATE sf+38,25
ft=FRAC(t*g1+g2-w9/360)*24
@prtime
PRINT " LST";
LOCATE sf+52,25
ft=FRAC(t*g1+g2)*24
@prtime
PRINT " GST";
RETURN
PROCEDURE prtime
PRINT USING "##!",INT(ft)+100,":";
ft=FRAC(ft)*60
PRINT USING "##!",INT(ft)+100,":";
PRINT USING "##",INT(FRAC(ft)*60)+100;
RETURN
PROCEDURE sun
REM Where is the sun?
t=t7+(TIMER-tstart)/17280000
gst=t*g1+g2
lst=FRAC(gst-w9x/24)*24
nsun=pday*(sepoch+t)
lnsun=(nsun+see*SIN(nsun+dseg)+seg) MOD p2
REM Ecliptic to equatorial conversion
REM enter with lnsun=ecliptic longitude, ltsun=ecliptic latitude
decsun=ASIN(SIN(ltsun)*cobliq+COS(ltsun)*sobliq*SIN(lnsun))
rasun=(ATN(TAN(lnsun)*cobliq-(TAN(ltsun)*sobliq/COS(lnsun)))+p2) MOD p2
IF ABS(rasun-lnsun)>pd2
rasun=(rasun+3*PI) MOD p2
ENDIF
REM Equatorial to local horizon conversion
hangle=(p2/24*lst-rasun+p2) MOD p2
sdecsun=SIN(decsun)
cdecsun=COS(decsun)
altsun=ASIN(sdecsun*sl9p0+cdecsun*cl9p0*COS(hangle))
azsun=ACOS((sdecsun-sl9p0*SIN(altsun))/cl9p0/COS(altsun))
IF SIN(hangle)>0
azsun=p2-azsun
ENDIF
xxtt%=xx%(mxsps%)
yytt%=yy%(mxsps%)
gcdecsun=90-decsun/p0
gcbsin=SIN(gcdecsun*p0)
gcbcos=COS(gcdecsun*p0)
yy%(mxsps%)=1.11111111*gcdecsun
sunlong=(rasun/p0-FRAC(gst)*360+540) MOD 360
sunlng=180-((360+sunlong) MOD 360)
xx%(mxsps%)=1.77777777*sunlong
IF (xxtt%<>xx%(mxsps%) OR yytt%<>yy%(mxsps%)) AND NOT radaron!
COLOR 2
CIRCLE xxtt%,yytt%,4
COLOR 1
CIRCLE xx%(mxsps%),yy%(mxsps%),4
ENDIF
RETURN
PROCEDURE map
CLS
ARRAYFILL xx%(),-1
ARRAYFILL yy%(),-1
xx%(mxsps%)=-10
yy%(mxsps%)=-10
IF mapon!
IF NOT radaron!
RESTORE map
FOR mj%=0 TO 199
READ lvt%(mj%)
NEXT mj%
green!=FALSE
FOR my%=0 TO 199
ox%=0
nx%=640
lvs%=lvt%(my%)
REPEAT
IF lvs%<>0
READ nx%
ENDIF
IF green!
COLOR 3
ELSE
COLOR 0
ENDIF
DRAW ox%,my% TO nx%,my%
ox%=nx%
IF lvs%<>0
green!=NOT green!
ENDIF
DEC lvs%
UNTIL lvs%<=0
IF green!
COLOR 3
DRAW nx%,my% TO 640,my%
ENDIF
NEXT my%
ELSE
COLOR 3
FOR lvs%=10 TO 80 STEP 10
FOR my%=0 TO 360 STEP 10
ox%=SINQ(my%)*lvs%+100
nx%=320-COSQ(my%)*lvs%*2.4
PLOT nx%,ox%
NEXT my%
NEXT lvs%
ENDIF
ENDIF
IF NOT radaron!
yy%(0)=1.11111111*(90-l9)
wx5=w9+180
IF wx5>=360
wx5=wx5-360
ENDIF
xx%(0)=1.77777777*(360-wx5)
COLOR 2
CIRCLE xx%(0),yy%(0),3
COLOR 1
PLOT xx%(0),yy%(0)
ELSE
COLOR 3
PLOT 320,100
FOR my%=0 TO 360
ox%=SINQ(my%)*90+100
nx%=320-COSQ(my%)*90*2.4
PLOT nx%,ox%
NEXT my%
ENDIF
RETURN
REM World map data (by John Logajan) in scanned form (for data compression),
REM left to right, top to bottom (0-639, 0-199.)
REM The first 200 datums represent the number of color transitions per each
REM line. The remaining datums represent each X coordinate at which the
REM transitions occur -- it is up to the software to keep track of the Y
REM coordinate based on the transitions-count-per-line data.
map:
DATA 0,0,0,0,0,0,0,2,4,4,8,12,12,18,18,22,16,10,24,20,21,20,19,18,13,10,12,14
DATA 16,17,14,12,12,16,18,18,18,16,18,20,18,20,18,10,12,8,10,12,12,16,20,18,20
DATA 18,14,20,22,16,16,16,16,14,8,10,10,10,6,12,14,12,14,12,20,14,14,20,18,18
DATA 18,18,14,12,14,12,12,12,18,18,16,20,16,12,14,16,12,10,10,10,14,16,18,18,12
DATA 16,20,14,18,14,10,10,14,10,10,10,12,14,12,12,13,11,10,8,12,12,10,8,8,8,8,6
DATA 6,6,6,6,6,6,8,8,10,6,6,6,6,6,4,6,6,6,8,6,4,4,4,2,4,4,2,4,4,2,4,4,0,0,0,0,0
DATA 2,2,2,2,2,4,8,6,6,8,8,4,6,6,6,6,6,4,5,2,0,0,0,0,0,0,0,0,0,0,0,0,0,236,283
DATA 163,201,207,285,159,196,203,300,157,182,198,297,352,369,485,495,146,156
DATA 164,177,189,194,200,290,339,369,483,498,145,159,162,185,191,288,340,360
DATA 490,496,501,507,114,117,121,126,135,139,146,159,161,186,190,287,342,354
DATA 356,365,497,509,100,106,112,117,148,158,160,182,193,288,346,351,358,362
DATA 436,443,496,520,99,106,113,116,125,131,136,139,141,144,149,156,159,180,196
DATA 286,423,443,479,523,567,575,135,138,148,154,175,179,216,287,418,432,473
DATA 523,565,578,581,589,98,111,161,171,218,286,416,427,470,522,99,110,114,121
DATA 126,132,137,142,146,153,159,178,180,185,220,284,414,423,443,448,462,549
DATA 569,576,97,110,111,135,137,141,145,154,160,189,220,282,411,419,442,450,452
DATA 551,567,587,0,5,41,45,98,109,110,136,145,155,160,195,220,282,411,421,439
DATA 551,554,591,637,3,31,61,88,93,114,139,146,154,170,199,222,282,357,376,414
DATA 422,438,605,638,0,30,75,79,107,146,158,165,169,182,201,222,281,350,382,425
DATA 434,438,632,0,4,24,121,128,138,142,171,184,202,226,276,345,388,396,402,406
DATA 636,0,9,24,122,126,174,182,206,224,267,342,393,397,15,29,175,183,211,224
DATA 261,343,394,397,19,22,166,186,210,224,259,277,282,284,294,342,16,21,164
DATA 169,174,180,208,225,250,276,296,340,360,363,0,8,13,24,162,166,175,180,205
DATA 227,249,277,295,337,359,360,0,14,19,27,159,165,175,191,206,228,248,279,291
DATA 333,357,358,639,25,159,181,191,194,206,229,245,306,309,329,352,357,636,24
DATA 155,181,193,199,203,231,246,328,351,357,631,24,153,181,197,233,245,328,352
DATA 357,597,604,627,28,56,61,152,182,197,203,207,239,244,329,354,360,596,605
DATA 617,32,52,73,155,180,199,201,209,311,315,329,353,359,585,588,596,603,613
DATA 37,50,75,156,181,211,307,317,330,336,340,350,352,355,358,571,599,611,36,43
DATA 47,50,78,161,183,212,307,317,341,350,352,354,357,569,597,610,32,40,45,47
DATA 79,165,183,212,309,316,341,349,357,566,596,611,27,37,82,174,179,215,305
DATA 307,310,318,334,340,343,346,356,566,596,608,26,29,83,86,87,174,178,219,302
DATA 308,310,320,335,342,347,569,572,574,596,609,20,25,83,86,87,176,179,221,302
DATA 308,312,321,329,570,571,575,596,605,84,87,90,143,147,177,179,221,303,308
DATA 311,324,328,570,571,575,597,602,626,629,5,7,86,88,92,177,179,222,301,308
DATA 310,323,326,570,571,575,598,602,91,216,312,321,323,570,572,576,597,600,92
DATA 214,217,222,310,314,321,570,572,576,595,597,95,211,216,221,318,570,572,577
DATA 98,161,166,206,214,224,315,570,572,574,99,159,163,165,168,207,216,223,314
DATA 568,572,575,99,158,161,214,316,410,414,566,572,575,586,588,99,167,173,213
DATA 318,374,378,406,412,426,428,565,571,573,582,587,99,164,168,172,175,210,317
DATA 373,379,383,386,404,409,424,428,563,571,576,581,583,99,163,166,173,178,197
DATA 202,205,305,345,347,372,389,405,411,561,571,580,98,163,166,174,177,195,303
DATA 327,329,332,338,345,350,370,391,405,411,559,568,579,98,196,304,326,335,337
DATA 339,349,352,370,377,385,393,407,412,553,568,575,99,193,304,324,334,338,342
DATA 352,354,409,413,551,568,572,99,189,304,321,325,327,334,338,346,353,354,363
DATA 366,410,413,535,536,549,568,573,100,188,303,320,324,326,334,338,348,351
DATA 355,362,366,408,414,533,535,539,542,548,568,573,100,187,303,321,341,350
DATA 356,364,366,407,415,531,541,549,567,572,102,186,304,319,342,348,357,363
DATA 368,410,415,538,542,550,563,571,103,186,308,317,320,339,345,348,358,362
DATA 369,538,544,551,561,571,104,186,310,313,318,340,361,367,378,382,383,534
DATA 544,551,556,571,105,185,308,340,363,367,377,381,383,534,544,549,552,569
DATA 108,182,305,340,382,535,551,563,111,180,303,346,356,362,381,535,550,559
DATA 112,177,303,348,355,366,381,537,551,555,113,117,118,176,302,353,355,537
DATA 551,554,113,117,119,176,302,538,114,118,120,162,168,177,295,297,301,406
DATA 410,537,116,120,121,151,172,177,290,293,294,296,300,407,410,537,115,121
DATA 123,148,172,178,298,382,383,408,411,535,117,122,124,148,173,178,180,183
DATA 294,381,384,410,414,534,120,123,125,148,174,178,294,382,385,412,419,533
DATA 120,124,127,147,175,177,180,182,293,383,386,412,416,421,428,436,438,532
DATA 534,537,122,125,128,147,181,183,292,384,386,425,439,531,533,537,124,126
DATA 130,147,171,179,291,384,388,426,442,529,533,536,35,37,39,40,132,147,169
DATA 173,176,183,290,386,389,427,442,482,483,524,534,535,38,40,41,43,132,148
DATA 159,166,289,387,389,426,443,478,483,513,514,519,41,45,132,149,159,165,184
DATA 189,290,387,390,425,449,475,484,510,514,518,42,45,132,149,158,165,185,194
DATA 290,387,392,423,449,473,486,509,513,518,135,165,187,191,197,201,291,388
DATA 393,423,449,471,486,509,513,517,534,538,138,164,198,201,291,389,394,421
DATA 450,469,488,510,533,538,141,164,290,390,395,418,450,467,487,512,533,538
DATA 145,171,290,391,395,414,450,465,487,491,493,513,532,537,155,173,289,394
DATA 396,412,451,463,493,514,533,537,156,173,290,395,396,407,452,463,494,515
DATA 534,541,160,172,290,404,452,463,495,515,534,537,538,541,164,172,191,198
DATA 290,398,414,418,453,463,495,498,501,515,534,537,540,544,166,172,187,199
DATA 292,398,404,412,454,462,495,498,502,515,532,533,536,544,167,173,185,212
DATA 293,411,455,462,495,497,504,512,531,533,536,543,167,174,177,181,184,212
DATA 295,411,455,461,462,464,495,498,506,510,529,532,537,545,171,214,296,410
DATA 456,460,461,465,494,499,506,508,528,530,538,545,174,178,180,216,297,409
DATA 461,466,494,499,537,546,181,218,298,409,461,466,495,501,527,530,536,538
DATA 540,546,182,225,301,324,328,408,462,465,489,491,496,503,526,531,540,545
DATA 182,228,303,319,329,407,489,495,498,504,523,533,182,230,330,405,490,497
DATA 499,504,521,531,182,230,335,404,492,498,500,504,518,529,180,230,337,403
DATA 493,500,517,530,546,548,178,232,336,400,492,504,515,532,534,538,541,543
DATA 546,549,157,158,177,231,336,398,496,505,515,532,533,535,537,542,546,549
DATA 157,159,176,237,335,376,381,397,497,505,515,529,532,534,546,548,551,562
DATA 157,158,176,241,336,375,380,395,498,509,515,529,532,536,546,549,552,567
DATA 176,244,336,394,499,510,515,528,531,535,554,571,177,251,337,392,500,510
DATA 516,527,531,541,544,553,554,576,589,591,175,253,339,391,502,509,523,526
DATA 532,535,536,539,544,547,551,553,556,578,589,593,175,258,340,390,503,509
DATA 532,535,537,540,562,580,588,592,175,258,341,390,505,510,532,535,538,540
DATA 558,560,565,582,585,591,595,597,176,259,342,391,512,523,558,560,566,582
DATA 586,588,595,598,178,259,342,390,509,525,543,546,566,584,179,259,343,391
DATA 517,547,569,576,580,584,180,258,343,391,531,535,539,544,570,575,581,587
DATA 603,606,180,257,343,393,539,542,582,589,605,609,181,255,344,393,551,557
DATA 572,574,608,609,182,254,344,393,406,409,551,564,572,575,12,13,184,253,342
DATA 392,406,409,551,564,572,576,12,16,184,251,342,393,404,410,544,547,550,562
DATA 571,576,185,251,341,393,404,410,542,562,571,579,616,618,186,251,340,392
DATA 400,410,541,565,571,579,616,618,189,251,340,391,398,409,537,568,570,580
DATA 617,619,637,0,192,251,340,390,398,408,537,580,635,638,195,250,341,386,398
DATA 408,536,581,635,638,195,250,342,384,398,408,535,583,195,249,342,382,398
DATA 407,421,423,530,585,612,613,195,248,343,383,397,407,418,420,525,586,612
DATA 616,195,248,344,383,396,406,522,588,614,618,194,246,345,384,396,405,522
DATA 589,194,240,345,384,397,405,521,590,194,237,345,383,397,405,521,592,194
DATA 235,346,381,399,404,521,592,194,234,346,379,521,593,193,234,347,379,522
DATA 593,193,234,348,378,523,594,192,233,349,377,524,593,192,231,350,375,524
DATA 593,192,230,350,375,525,593,192,230,352,373,525,592,192,227,351,372,525
DATA 543,558,591,192,226,352,369,524,541,559,590,191,225,354,365,524,533,560
DATA 589,627,629,191,219,562,588,627,631,190,220,563,588,628,633,189,219,568
DATA 587,630,638,188,218,570,586,630,637,189,215,574,581,628,637,188,210,629
DATA 635,188,210,577,584,626,634,188,207,577,584,624,633,188,207,578,584,623
DATA 630,5,7,187,205,579,582,620,628,6,7,187,205,617,626,187,204,616,625,185
DATA 201,616,624,185,204,617,620,185,204,185,201,442,446,185,200,442,445,186
DATA 198,186,198,213,218,186,199,214,216,188,200,189,205,252,257,193,205,255
DATA 257,237,241,215,218,212,218,212,220,207,219,205,216,545,551,203,215,497
DATA 511,516,528,544,566,196,214,409,425,466,577,196,211,394,444,460,582,192
DATA 210,379,446,456,587,593,601,185,189,192,210,332,344,369,607,184,211,306
DATA 618,173,178,184,212,298,625,137,158,171,212,295,624,100,113,127,213,287
DATA 620,97,114,125,213,279,617,70,88,95,211,275,613,54,209,271,610,0,219,262
DATA 610,627,226,256
REM -- SYMBOL TABLE -- (ala Clark and Tilley)
REM A0 = SEMI-MAJOR axis
REM A9 = Azimuth
REM Cn = COSines, C(J,K) also
REM E0 = eccentricity of orbit
REM E8 = observer horizion
REM E9 = satellite elevation
REM G0 = GM of Earth
REM G1 = Sidereal/Solar
REM G2 = New Year's sidereal time
REM G7 = GHA Aries
REM H1 = Hours duration
REM H3 = Hour epoch
REM H4 = Hour
REM H9 = observer height
REM K0 = initial orbit #
REM K = orbit counter
REM K7 = INT(T)
REM L5 = SSP LATITUDE
REM L8 = GEOCENTRIC latitude
REM L9 = observer longitude
REM M = mean anomaly
REM M0 = mean anomaly of ref epoch
REM M3 = ref epoch minutes
REM M4 = integer minutes
REM M5 = difference in Transcendental Eq.
REM N0 = mean motion
REM O, O0 = R.A.A.N.
REM P0,P1,P2 variations on a theme of PI
REM Q,Q0 = total orbits
REM R = ? in plane of orbit
REM R5 = range
REM R6 = previous range
REM R9 intermediate for GEOCENTRICs
REM Ss used for SIN
REM T0 = ref time in orbit days
REM W, W0 arg of perigee
REM W5 = SSP W. long.
REM W9 = observers W. long
REM X0,Y0,R coord in plane of orbit
REM X1,Y1,Z1 " " INERTIAL CELESTIAL
REM X,Y,Z in GEOCENTRIC coordinates
REM X9,Y9,Z9 are observer's GEOCENTRIC coordinates
REM X5,Y5,Z5 ==> R5 vector from observer to satellite
REM X8,Y8,Z8 are observer's LOCAL Coordinates