Some years ago a friend showed me a program that he had written on his C-128. It showed a planet with an orbiting object. As the object orbited the planet, it left a trail of dots so one could see the orbit shape.
I found it an interesting program and converted it to the QL. Some time later I wrote a short version for the T/S 2068. Just the other day I finally wrote a version for the T/S 1000 (after blowing the dust off my T/S 1000). The QL and the T/S 1000 versions are functionally the same. The T/S 1000 version was taken directly from the QL version. I would have changed the T/S 2068 version to be equal to the other two, but my 2068 is on the fritz and I am lucky to just get it to load and print out. I am sure that 2068ers out there can read the other two versions and modify the 2068 version to match (Do I see a future article?).
Here is how the program works. It starts off by drawing a circle to represent the planet (a dot for the 1000). Then the orbiter appears. In time you will see the orbiter move around the planet, leaving a trail of dots. Eventually the dots will disappear, and the trail is kept the same length.
This program would be boring if you could not alter the orbiter. You can do this. Using the arrow keys (and the joystick on the QL) you can fire a directional rocket on the orbiter, altering its trajectory. If you press the up arrow key, you will add thrust in that direction, and so on with the other keys.
What this means is that you can change the shape of the orbit. Add a thrust in the opposite direction that the orbiter is traveling and you will slow it down, thereby giving it a more eliptical orbit. Doing this again at the right point and you can give it a tighter circular orbit.
You can add lots of thrust on the QL version with not too many problems. The 1000 version is a bit more sensitive. When an orbiter goes off the screen on the QL, the QL ignores any points off the screen. Eventually, the orbiter will come back. Not so on the 1000 version. If the orbiter goes off the screen, you will get an error. I’ll leave it up to you if you want to change it.
With this program it’s easy to demonstrate Kepler’s Second Law dealing with orbital paths, stating that a orbital object sweeps out equal area in equal time. In other words, the closer to the planet, the tighter the orbit, and the faster it travels. For a detailed description, watch reruns of COSMOS.
QL version
100 WINDOW #1,512,256,0,0 : PAPER 0
110 DIM trail(50,2)
120 CLS
130 SCALE 1000,0,0
140 INK 4 : FILL 1 : CIRCLE 500,
500,30
150 FILL 0 : INK 7
160 LET xpos=500 : LET ypos=750
170 LET xmov=9 : LET ymov=0
180 LET top=0 : LET last=1
190 REPeat loop
200 LET top=top+1
210 IF top>50 THEN LET top=1
220 POINT xpos,ypos
230 LET trail(top,1)=xpos : LET
trail(top,2)=ypos
240 LET dxpos=xpos-500
250 LET dypos=ypos-500
260 LET distance=(dxpos^2+dypos
^2)^.5
270 LET gravity=20000/distance^2
280 LET xmov=xmov-gravity*dxpos
/distance
290 LET ymov=ymov-gravity*dypos
/distance
300 LET key = KEYROW(1)
310 IF key<>0 THEN joystick
320 LET xpos=xpos+xmov
330 LET ypos=ypos+ymov
340 IF top+1=last OR top-49=last
THEN
350 INK 0 : POINT trail(last,1)
,trail(last,2) : INK 7
360 LET last=last+1
370 IF last>50 THEN LET last=1
380 END IF
390 END REPeat loop
400 DEFine PROCedure joystick
410 BEEP 100,1
420 IF key=4 OR key=6 OR key=20
THEN LET ymov=ymov+1
430 IF key=128 OR key=144 OR
key=130 THEN LET ymov=ymov-1
440 IF key=2 OR key=6 OR key=130
THEN LET xmov=xmov-1
450 IF key=16 OR key=144 OR
key=20 THEN LET xmov=xmov+1
460 END DEFine joystick
T/S 1000 Version
10 CLS
20 DIM T(10,2)
30 LET PX=32
40 LET PY=21
50 PLOT PX,PY
100 LET XPOS=32
110 LET YPOS=4
130 LET XMOV=4
140 LET YMOV=0
150 LET TOP=0
160 LET LAST=1
200 REM LOOP
210 LET TOP=TOP+1
220 IF TOP>50 THEN LET TOP=1
230 PLOT XPOS,YPOS
240 LET T(TOP,1)=XPOS
250 LET T(TOP,2)=YPOS
260 LET DXPOS=XPOS-PX
270 LET DYPOS=YPOS-PY
273 LET A=ABS (DXPOS)**2
275 LET B=ABS (DYPOS)**2
280 LET TEMP=ABS (A+B)
285 LET DIST=SQR TEMP
290 LET GRAV=6/SQR (DIST)
300 LET XMOV=XMOV-GRAV*DXPOS/DI
ST
310 LET YMOV=YMOV-GRAV*DYPOS/DI
ST
320 LET XMOV=XMOV-(INKEY$="5")+
(INKEY$="8")
330 LET YMOV=YMOV+(INKEY$="7")-
(INKEY$="6")
340 LET XPOS=XPOS+XMOV
350 LET YPOS=YPOS+YMOV
360 IF (TOP+1=LAST) OR (TOP-9=L
AST) THEN GOSUB 1000
370 GOTO 200
1000 REM REMOVE TRAIL
1010 UNPLOT T(LAST,1),T(LAST,2)
1020 LET LAST=LAST+1
1030 IF LAST>10 THEN LET LAST=1
1040 RETURN
T/S 2068 Version
10 BRIGHT 1 : PAPER 0: BORDER
0: CLS
20 INK 4: CIRCLE 128,96,7
30 INK 7
40 LET xpos=128: LET ypos=140
50 LET xmov=4: LET ymov=0
60 PLOT xpos,ypos
70 LET dxpos=xpos-128
80 LET dypos=ypos-96
85 LET zz=(ABS (dxpos)↑2+ABS (
dypos)↑2)
90 LET dist=SQR zz
100 LET grav=600/dist↑2
110 LET xmov=xmov-grav*dxpos/di
st
120 LET ymov=ymov-grav*dypos/di
st
130 LET xpos=xpos+xmov
140 LET ypos=ypos+ymov
200 GO TO 60
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.