1
0
mirror of https://github.com/mbirth/gwbasic.git synced 2024-09-19 16:53:26 +01:00
gwbasic/SONNE.BAS

49 lines
1.2 KiB
QBasic
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

10 'Programm: SONNE.BAS
20 'Funktion: Simulation der Planeten-
30 ' gravitation
40 'Sprache: GW-Basic
50 'Autor: Axel Werner
60 '(C)1991 DMV Widuch GmbH & Co. KG
70 DEFINT I,S,A,F
80 INPUT "A: ",A
90 IF A>5 THEN A=5
100 IF A<1 THEN A=1
110 FOR I=1 TO A
120 PRINT"XP("I"),YP("I"),ZP("I"): ";
130 INPUT"",XP(I),YP(I),ZP(I)
140 PRINT"DXP("I"),DYP("I"),DZP("I"): ";
150 INPUT"",DXP(I),DYP(I),DZP(I)
160 PRINT"M("I"): ";:INPUT"",M(I)
170 NEXT
180 INPUT"MS: ",M(0)
190 XP(0)=0:YP(0)=0:ZP(0)=0
200 SCREEN 2:CLS:KEY OFF
210 WINDOW SCREEN(-320,-250)-(320,250)
220 G=.006672
230 FOR I=0 TO A
240 NXP=XP(I)+DXP(I):NYP=YP(I)+DYP(I)
250 NZP=ZP(I)+DZP(I)
260 FOR S=0 TO A
270 IF I=S THEN 350
280 X2=XP(S)-XP(I):Y2=YP(S)-YP(I)
290 Z2=ZP(S)-ZP(I)
300 D=SQR(X2*X2+Y2*Y2+Z2*Z2)
310 GK=G*M(S)*M(I)/(D*D)
320 B=GK/(2*M(I))
330 X1=X2*B/D:Y1=Y2*B/D:Z1=Z2*B/D
340 NXP=NXP+X1:NYP=NYP+Y1:NZP=NZP+Z1
350 NEXT
360 DXP(I)=NXP-XP(I):DYP(I)=NYP-YP(I)
370 DZP(I)=NZP-ZP(I):GOTO 400
380 X%=XP(I):Y%=YP(I):Z%=ZP(I)
390 F=0:GOSUB 450
400 X%=NXP:Y%=NYP:Z%=NZP:F=1:GOSUB 450
410 XP(I)=NXP:YP(I)=NYP:ZP(I)=NZP
420 NEXT
430 IF INKEY$="" THEN 230
440 END
450 X%=X%+Z%/3
460 Y%=Y%-Z%/3
470 PSET(X%,Y%),F
480 RETURN