5 REM TWOSUN.BAS 7 REM Modified for TRS-80 Model 100 with Disk/Video Interface by Leonard Erickson 70465,203 10 REM This program was adapted from the original by Caxton C. Foster 20 REM as published in Creative Computing, Vol 7, No 12, December, 1981. 30 E$=CHR$(27):E1$=E$+"E":Y1$=E$+"T":X1$=E$+"U":J$=E$+"i":K$=E$+"k" 40 Y$=E$+"Y":X5$=E$+"Q" 50 PRINT E1$;TAB(36)"TWO SUNS":PRINT 60 PRINT "This program simulates the celestral movement of a planet in a dual sun system." 70 PRINT "The first sun is assumed to have the same mass and luminosity of our sun (1)." 80 PRINT "The mass and luminosity of the second sun is entered by the user relative to" 90 PRINT "the first sun. A value less than 1 would indicate a less massive or luminous" 100 PRINT "star and visa versa. The initial X coordinate and velocity in the Y coordinate" 110 PRINT "of the first sun is entered by the user: use values of -40 to 40 for X and -1" 120 PRINT "to 1 for velocity. The parameters of the second sun are computed from those of" 130 PRINT "the first. The mass of the planet is assumed to be negliable compared to that" 140 PRINT "of the suns. The X coordinate and velocity in the Y coordinate of the planet" 150 PRINT "are entered by the user: values between -40 and 40 for X and between -1 and 1" 160 PRINT "for the velocity should be used. All objects are initially at Y=0 with zero" 170 PRINT "velocity in the X coordinate. The positions of the two suns and planet are" 180 PRINT "displayed graphically. Data concerning the date, time, and fraction of sun" 190 PRINT "shine reaching the planet are displayed on the 25th line. A value of 1 for the" 200 PRINT "sun shine is typical of our earth system." 210 PRINT J$;X1$;Y$;"88Hit when ready to continue.";K$:ZZ$=INPUT$(1) 220 PRINT E1$;"It is suggested that the user try one or more of the following systems as" 230 PRINT "examples of how the program is intended to operate before plugging in his own" 240 PRINT "values.":PRINT :PRINT "System #1 (stable)":PRINT "Sun #2 : Mass = 1 Luminosity = 1" 250 PRINT "Sun #1 : X coordinate = 15 Velocity in Y coordinate = 0.15" 260 PRINT "Planet : X coordinate = 20 Velocity in Y coordinate = 0.6":PRINT 270 PRINT "System #2 (stable)":PRINT "Sun #2 : Mass = 2 Luminosity = 2" 280 PRINT "Sun #1 : X coordinate = 5 Velocity in Y coordinate = 0.4" 290 PRINT "Planet : X coordinate = 20 Velocity in Y coordinate = 0.39" 300 PRINT :PRINT "System #3 (unstable)":PRINT "Sun #2 : Mass = 2 Luminosity = 1" 310 PRINT "Sun #1 : X coordinate = 10 Velocity in Y coordinate = 0.2" 320 PRINT "Planet : X coordinate = 15 Velocity in Y coordinate = 0.75" 330 ZZ$=INPUT$(1):PRINT Y1$ 340 T=0:B=1000:DIM A$(3),O$(3),V1(3),V2(3),X(3),X1(3),Y(3),Y1(3) 350 O$(1)="*":O$(2)="*":O$(3)="." 360 PRINT E1$;TAB(30)"Enter data on Sun #2":PRINT 370 INPUT "Mass (Sol=1) = ";M2:INPUT "Luminosity (Sol=1) = ";L2 380 PRINT E1$;TAB(30)"Enter data on Sun #1":PRINT 390 INPUT "Initial X coordinate (-40 to 40) = ";X(1):X(2)=-X(1)/M2 400 INPUT "Initial velocity in Y coordinate (-1 to 1) = ";V2(1):V2(2)=-V2(1)/M2 410 PRINT E1$;TAB(30)"Enter data on planet":PRINT 420 INPUT "Initial X coordinate (-40 to 40) = ";X(3) 430 INPUT "Initial velocity in Y coordinate (-1 to 1) = ";V2(3):D=1:PRINT E1$;X5$ 440 REM R1 IS THE DISTANCE BETWEEN THE SUNS 450 R1=(ABS(X(1)-X(2))^2+ABS(Y(1)-Y(2))^2)^.5 460 REM R2 IS THE DISTANCE FROM THE PLANET TO SUN #1 470 R2=(ABS(X(1)-X(3))^2+ABS(Y(1)-Y(3))^2)^.5 480 REM R3 IS THE DISTANCE FROM THE PLANET TO SUN #2 490 R3=(ABS(X(2)-X(3))^2+ABS(Y(2)-Y(3))^2)^.5 500 REM X1( IS ACCELERATION IN THE X DIRECTION 510 X1(1)=M2*(X(2)-X(1))/R1^3 520 X1(2)=-X1(1)/M2 530 X1(3)=(X(1)-X(3))/R2^3+M2*(X(2)-X(3))/R3^3 540 REM Y1( IS ACCELERATION IN THE Y DIRECTION 550 Y1(1)=M2*(Y(2)-Y(1))/R1^3 560 Y1(2)=-Y1(1)/M2 570 Y1(3)=(Y(1)-Y(3))/R2^3+M2*(Y(2)-Y(3))/R3^3 580 FOR I=1TO 3:V1(I)=V1(I)+D*X1(I) 590 V2(I)=V2(I)+D*Y1(I) 600 X(I)=X(I)+D*V1(I) 610 Y(I)=Y(I)+D*V2(I) 620 X9=X(I):Y9=Y(I):GOSUB 760:NEXT 630 REM CALCULATE FOOTING INFORMATION 640 T0=T0+1 650 IF Y(1)<0THEN F1=1 660 IF Y(1)>0AND F1=1THEN M=M+1:F1=0 670 IF Y(3)<0THEN F2=1 680 IF Y(3)>0AND F2=1THEN Y=Y+1:F2=0 690 REM DISPLAY DATA ON 25TH LINE 700 PRINT Y1$;X1$;J$;Y$;"8 Year=";Y;"Sunth=";M;"Time=";T0; 710 S=1/R2^2+L2/R3^2:PRINT USING"Shine=##.##^^^^";100*S; 720 IF S>T THEN T=S 730 IF S40THEN T1=40 790 IF T1<-40THEN T1=-40 800 IF T2>12THEN T2=12 810 IF T2<-12THEN T2=-12 820 REM SHIFT ORIGIN 830 T1=T1+40:T2=13-T2 840 REM DISPLAY OBJECT ON SCREEN 850 IF F=0THEN F=1:GOTO 870 860 PRINT Y$;A$(I);" " 870 A$(I)=CHR$(T2+31)+CHR$(T1+31) 880 PRINT Y$;A$(I);O$(I) 890 RETURN