home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FreeWare Collection 2
/
FreeSoftwareCollection2pd199x-jp.img
/
fbasic
/
prelude
/
pds0a
/
fractal
/
frademo1.bas
next >
Wrap
BASIC Source File
|
1990-06-14
|
14KB
|
431 lines
100 ' F-BASIC386 SAMPLE PROGRAM % COPYRIGHT FUJITSU LIMITED 19900506
110 ' PUBLIC DOMAIN SOFTWARE by PRELUDE FMC(Fujitsuマイコンクラブ)
120 ' ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
130 ' ★ ソフト名:フラクタル・デモ PART1 V4 ★
140 ' ★ 登録名 :FRADEMO01.BAS ★
150 ' ★ 登録者 :PRELUDE(Yuuichi Sasaki) ★
160 ' ★ 動作確認:FM-TOWNS 2 F-BASIC386 V1.1L20 ★
170 ' ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
180 '
190 *環境 ' *** 環境設定 ***
200 CLEAR,,1024:WIDTH 80,25:CONSOLE 0,24,1
210 COLOR 5,1,0,4:CLS:SCREEN@ 1:PASTEL:S=1
220 WINDOW (0,0)-(319,239):VIEW (0,0)-(319,239)
230 ON ERROR GOTO *異常
240 INTERVAL 2:ON INTERVAL GOSUB *時計:INTERVAL ON
250 ON KEY(1) GOSUB *PF1:KEY(1) ON
260 ON KEY(2) GOSUB *PF2:KEY(2) ON
270 ON KEY(3) GOSUB *PF3:KEY(3) ON
280 ON KEY(4) GOSUB *PF4:KEY(4) ON
290 ON KEY(5) GOSUB *PF5:KEY(5) ON
300 ON KEY(6) GOSUB *PF6:KEY(6) OFF
310 KEY 1," 終了":KEY 2,"SIMPOSE"
320 KEY 3," 書庫":KEY 4," MENU"
330 KEY 5," LOAD":KEY 6," 初期"
340 KEY 7," PF7":KEY 8," PF8"
350 KEY 9," PF9":KEY 10," PF10"
360 MOUSE 0
370 ON MOUSE(2) GOSUB *左押す:MOUSE(2) ON
380 ON MOUSE(4) GOSUB *右押す:MOUSE(4) ON
390 MOUSE 1,319,239,0
400 GOTO *MENU
410 '
420 *時計 ' *** 時計割込み処理 ***
430 INTERVAL OFF
440 TDT$=DATE$:TTM$=TIME$:TXX=POS(0):TYY=CSRLIN
450 LOCATE 10,1:PRINT TDT$;"†";TTM$;"†"
460 LOCATE TXX,TYY:INTERVAL ON:RETURN
470 '
480 *右押す ' *** マウス割込(終了) ***
490 MOUSE(2) OFF:MOUSE(4) OFF:INTERVAL OFF:RETURN *PF1
500 'MOUSE(2) ON:MOUSE(4) ON:INTERVAL ON:RETURN *PF1
510 '
520 *左押す ' *** マウス割込(メニュー) ***
530 MOUSE(2) OFF:MOUSE(4) OFF:INTERVAL OFF
540 MOUSE(2) ON:MOUSE(4) ON:INTERVAL ON:GOTO *PF4
550 '
560 *PF1 ' *** 終了処理 ***
570 INTERVAL OFF:MOUSE 5:WIDTH 80,25:CONSOLE 0,25,0:END
580 '
590 *PF2 ' *** TV(スーパーインポーズ) ***
600 IF S<>1 THEN RETURN
610 IF SW=0 THEN SW=1:SIMPOSE ON ELSE SW=0:SIMPOSE OFF
620 RETURN
630 '
640 *PF3 ' *** FRA32A.TIF/FRA16A.TIFで保存 ***
650 LOCATE 0,0
660 PRINT"グラフィック画面を書庫(FRAxxA.TIF)に保存? Y で実行します。 "
670 IK$=INKEY$:IF IK$="Y" THEN GOTO 690 ELSE IF IK$="" THEN GOTO 670
680 GOTO 730
690 IF S=1 THEN KILL "\FILE\FRA32A.TIF"
700 IF S=1 THEN SAVE@ "\FILE\FRA32A.TIF",(0,0)-(319,239)
710 IF S=2 THEN KILL "\FILE\FRA16A.TIF"
720 IF S=2 THEN SAVE@ "\FILE\FRA16A.TIF",(0,0)-(639,479)
730 LOCATE 0,0
740 PRINT" "
750 RETURN
760 '
770 *PF4 ' *** メニュー表示 ***
780 SCREEN@ 1:S=1:WINDOW (0,0)-(319*S,239*S)
790 VIEW (0,0)-(319*S,239*S):COLOR 5,1,0,4:CLS:RUN':RETURN *MENU
800 '
810 *PF5 ' *** LOAD ***
820 LOCATE 0,0
830 PRINT"グラフィック画面を書庫(FRAxxA.TIF)から読む? Y で実行します。"
840 IK$=INKEY$:IF IK$="Y" THEN GOTO 860 ELSE IF IK$="" THEN GOTO 840
850 GOTO 880
860 IF S=1 THEN LOAD@ "\FILE\FRA32A.TIF"
870 IF S=2 THEN LOAD@ "\FILE\FRA16A.TIF"
880 LOCATE 0,0
890 PRINT" "
900 RETURN
910 '
920 *PF6 ' *** 初期 ***
930 TXY=POS(0):TYX=CSRLIN:GOSUB *読む:LOCATE 0,0
940 IF D$="X" THEN INPUT" X=";X
950 IF D$="Y" THEN INPUT" Y=";Y
960 IF D$="Z" THEN INPUT" Z=";Z
970 IF D$="R" THEN INPUT" R=";R
980 IF D$="D" THEN INPUT" DT=";DT
990 IF D$="T" THEN INPUT" T=";T
1000 IF D$="A" THEN INPUT" A=";A
1010 IF D$="B" THEN INPUT" B,B0=";B,B0
1020 IF D$="C" THEN INPUT" C=";C
1030 IF D$="K" THEN INPUT" K1,K2=";K1,K2
1040 LOCATE 0,0:PRINT" ":LOCATE TXY,TYX:RETURN
1050 '
1060 *異常 ' 異常処理。
1070 OPEN"A",#1,"\FILE\ERROR.BAS"
1080 PRINT#1,ERL,"Error number=";ERR,"Error line=";ERL
1090 CLOSE#1
1100 BEEP:RESUME NEXT
1110 '
1120 *MENU
1130 LOCATE 0,0:PRINT:PRINT
1140 PRINT "◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆"
1150 PRINT "1: VON KOCH CURVE"
1160 PRINT "2: FRACTAL BRANCH"
1170 PRINT "3: LEVY FLIGHT 2D"
1180 PRINT "4: AGGREGATION ON 2D LATTICE"
1190 PRINT "5: LORENZ MODEL"
1200 PRINT "6: ROSSLER MODEL"
1210 PRINT "7: DUFFING MODEL"
1220 PRINT "8: NONLINEAR OSILLATIONS"
1230 PRINT "◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆"
1240 GOSUB *読む:KY=VAL(D$):IF KY<1 OR KY>9 THEN KY=0
1250 ON KY GOSUB *PRO1,*PRO2,*PRO3,*PRO4,*PRO5,*PRO6,*PRO7,*PRO8
1260 GOTO *MENU
1270 '
1280 *読む ' 文字読み
1290 MOUSE(2) OFF:MOUSE 1,100,100,1
1300 MO=MOUSE (2,0):IF MO<>0 GOTO 1290
1310 MOX=MOUSE (0):' X 座標
1320 MOY=MOUSE (1):' Y 座標
1330 D$=CHR$(SCREEN (MOX/(4*S),MOY/(9.5!*S)))
1340 LOCATE 0,0:PRINT"選択=>";D$;" マウス左クリックで選択。 "
1350 MO=MOUSE (2,0):IF MO=0 GOTO 1310
1360 MO=MOUSE (2,0):IF MO<>0 GOTO 1360
1370 MOUSE 1,100,100,0::MOUSE(2) ON
1380 LOCATE 0,0:PRINT" ":RETURN
1390 '
1400 *PRO1
1410 COLOR 2,7,0,0:CLS:LINE(0,0)-(319,239),PASTEL,1,BF:KEY(6) OFF
1420 '
1430 ' % % % % % VON KOCH CURVE % % % % %
1440 '
1450 N=12:PI=3.14159!
1460 DIM X(2^(N+1)-2),Y(2^(N+1)-2)
1470 WINDOW(0,-2/3)-(1,0)
1480 VIEW(0,0)-(319,199)
1490 '
1500 A=SQR(1/3)*COS(PI/6)
1510 B=SQR(1/3)*SIN(PI/6)
1520 A1=A:A2=B:A3=B:A4=-A
1530 B1=A:B2=-B:B3=-B:B4=-A
1540 '
1550 X(0)=0:Y(0)=0
1560 FOR M=1 TO N
1570 L2=2^(M-1)-1:L1=L2*2+1:L3=L1*2
1580 FOR K=0 TO L2
1590 XX=X(L2+K):YY=Y(L2+K)
1600 X(L1+K)=A1*XX+A2*YY
1610 Y(L1+K)=A3*XX+A4*YY
1620 X(L3-K)=B1*XX+B2*YY+1-B1
1630 Y(L3-K)=B3*XX+B4*YY-B3
1640 PSET(X(L1+K),-Y(L1+K)),2
1650 PSET(X(L3-K),-Y(L3-K)),1
1660 NEXT K
1670 NEXT M:BEEP:BEEP:GOTO 1550
1680 '
1690 *PRO2
1700 COLOR 2,7,0,0:CLS:LINE(0,0)-(319,239),PASTEL,1,BF:KEY(6) OFF
1710 '
1720 ' % % % % % FRACTAL BRANCH % % % % %
1730 '
1740 N=12:PI=3.14159!
1750 DIM X(2^(N+1)-2),Y(2^(N+1)-2)
1760 WINDOW(0,-1/3)-(1,1/3)
1770 VIEW(0,0)-(319,199)
1780 '
1790 A=SQR(1/3)*COS(PI/6)
1800 B=SQR(1/3)*SIN(PI/6)
1810 A1=A:A2=B:A3=B:A4=-A
1820 D=2/3:B1=D:B2=0:B3=0:B4=-D
1830 '
1840 X(0)=0:Y(0)=0
1850 FOR M=1 TO N
1860 L2=2^(M-1)-1:L1=L2*2+1:L3=L1*2
1870 FOR K=0 TO L2
1880 XX=X(L2+K):YY=Y(L2+K)
1890 X(L1+K)=A1*XX+A2*YY
1900 Y(L1+K)=A3*XX+A4*YY
1910 X(L3-K)=B1*XX+B2*YY+1-B1
1920 Y(L3-K)=B3*XX+B4*YY-B3
1930 PSET(X(L1+K),-Y(L1+K)),2
1940 PSET(X(L3-K),-Y(L3-K)),1
1950 NEXT K
1960 NEXT M:BEEP:BEEP:GOTO 1840
1970 '
1980 *PRO3
1990 COLOR 6,7,0,0:CLS:LINE(0,0)-(319,239),PASTEL,1,BF:KEY(6) OFF
2000 '
2010 ' % % % % % LEVY FLIGHT 2-D % % % % %
2020 '
2030 D=1.8!
2040 DD=-1/D:P2=3.14159!*2
2050 XL=50+10^(-DD*3.5!):YL=XL
2060 WINDOW(-XL,-YL)-(XL,YL)
2070 VIEW(0,0)-(319,239)
2080 '
2090 *LEVY2
2100 X=0:Y=0:N=1:RANDOMIZE TIME:BEEP
2110 '
2120 *LEVY
2130 Z=(1-RND)^DD:W=RND*P2
2140 XX=X+Z*COS(W):YY=Y+Z*SIN(W)
2150 X=XX:Y=YY:PSET(X,Y),N/100 MOD 8:N=N+1
2160 IF YL<ABS(X) OR XL<ABS(X) GOTO *LEVY2 ELSE *LEVY
2170 '
2180 *PRO4
2190 COLOR 6,0,0,0:CLS:KEY(6) OFF
2200 '
2210 ' % % % % % Aggregation on 2D Lattice (10H/RUN) % % % % %
2220 '
2230 P=160:Q=120 ' Location of the seed
2240 R0=2 ' Initial value of R0
2250 PSET(P,Q),2:N=1
2260 FOR I=-20 TO 20:PSET(P+I,Q),2:PSET(P,Q+I),2
2270 NEXT I
2280 '
2290 *MAIN4
2300 R=R0*2 ' Particles appear at R
2310 RMAX=R0*4 ' Limit of moving area
2320 RX=INT((2*R+1)*RND)-R
2330 RV=R-ABS(RX)
2340 RY=RV*SGN(RND-.5!)
2350 X=RX+P:Y=RY+Q:BEEP
2360 '
2370 *LOOP4
2380 XB=X:YB=Y
2390 DISTR=ABS(X-P)+ABS(Y-Q)
2400 IF POINT(X,Y-1)=-1 OR POINT(X,Y+1)=-1 THEN GOTO *AGGR
2410 IF POINT(X-1,Y)=-1 OR POINT(X+1,Y)=-1 THEN GOTO *AGGR
2420 IF DISTR > RMAX THEN PRESET(X,Y):GOTO *MAIN4
2430 TWD(1)=0:TWD(2)=0
2440 TWD(INT(2*RND)+1)=SGN(RND-.5!)
2450 X=X+TWD(1):Y=Y+TWD(2):N=N+1:IF N=8 THEN N=1
2460 PRESET(XB,YB):PSET(X,Y),N
2470 GOTO *LOOP4
2480 '
2490 *AGGR
2500 PSET(X,Y),N
2510 IF DISTR > R0 THEN R0=DISTR
2520 GOTO *MAIN4
2530 '
2540 *PRO5
2550 SCREEN@ 0:S=2:COLOR 6,2,0,4:CLS:KEY(6) ON
2560 WINDOW(0,0)-(639,479):VIEW(0,0)-(639,479)
2570 '
2580 ' % % % % % LORENZ MODEL % % % % %
2590 '
2600 LOCATE 0,0:PRINT"初期:変数変更"
2610 X=10:Y=12:Z=15:R=50:DT=.002!:A=10:B=2.66667!
2620 DIM V(1,3),W(1,3),U(1):RESTORE 2950
2630 FOR I=0 TO 1
2640 FOR J=0 TO 3:READ W(I,J):NEXT J
2650 FOR J=0 TO 3:READ V(I,J):NEXT J
2660 WINDOW(W(I,0),W(I,1))-(W(I,2),W(I,3))
2670 VIEW(V(I,0),V(I,1))-(V(I,2),V(I,3))
2680 LINE(-200,-200)-(200,200),PSET,1,BF
2690 LINE(-200,0)-(200,0),PSET,4:LINE(0,-200)-(0,200),PSET,4
2700 NEXT I
2710 LOCATE 37,16:PRINT"X",:LOCATE 19,3:PRINT"Z",
2720 LOCATE 77,16:PRINT"Y",:LOCATE 60,3:PRINT"Z",
2730 DEF FNX(X,Y,Z,A,B,DT)=X+(-A*(X-Y))*DT
2740 DEF FNY(X,Y,Z,A,B,DT)=Y+(-X*Z+R*X-Y)*DT
2750 DEF FNZ(X,Y,Z,A,B,DT)=Z+(X*Y-B*Z)*DT
2760 '
2770 LOCATE 1,20
2780 PRINT"初期 X=";X;" Y=";Y;" Z=";Z;" R=";R;" DT=";DT;" A=";A;" B=";B
2790 WHILE 1
2800 LOCATE 1,21:PRINT"現在 X=";X;" "
2810 LOCATE 20,21:PRINT" Y=";Y;" "
2820 LOCATE 35,21:PRINT" Z=";Z;" "
2830 LOCATE 1,22:PRINT" R=";R;" DT=";DT;" A=";A;" B=";B;" "
2840 U(0)=X:U(1)=Y
2850 FOR I=0 TO 1
2860 WINDOW(W(I,0),W(I,1))-(W(I,2),W(I,3))
2870 VIEW(V(I,0),V(I,1))-(V(I,2),V(I,3))
2880 PSET(U(I),-Z),2
2890 NEXT I
2900 XX=FNX(X,Y,Z,A,B,DT)
2910 YY=FNY(X,Y,Z,A,B,DT)
2920 ZZ=FNZ(X,Y,Z,A,B,DT)
2930 X=XX:Y=YY:Z=ZZ
2940 WEND
2950 DATA -30,-100,40,5,10,50,309,349
2960 DATA -40,-100,50,5,330,50,629,349
2970 '
2980 *PRO6
2990 SCREEN@ 0:S=2:COLOR 6,2,0,4:CLS:KEY(6) ON
3000 WINDOW(0,0)-(639,479):VIEW(0,0)-(639,479)
3010 '
3020 ' % % % % % ROSSLER MODEL % % % % %
3030 '
3040 LOCATE 0,0:PRINT"初期:変数変更"
3050 X=0:Y=3:Z=0:DT=.006!:A=.5!:B=.4!:C=4.5!
3060 DIM V(1,3),W(1,3),U(1):RESTORE 3390
3070 FOR I=0 TO 1
3080 FOR J=0 TO 3:READ W(I,J):NEXT J
3090 FOR J=0 TO 3:READ V(I,J):NEXT J
3100 WINDOW(W(I,0),W(I,1))-(W(I,2),W(I,3))
3110 VIEW(V(I,0),V(I,1))-(V(I,2),V(I,3))
3120 LINE(-200,-200)-(200,200),PSET,1,BF
3130 LINE(-200,0)-(200,0),PSET,4:LINE(0,-200)-(0,200),PSET,4
3140 NEXT I
3150 LOCATE 37,11:PRINT"Y",:LOCATE 20,3:PRINT"X",
3160 LOCATE 77,11:PRINT"Z",:LOCATE 47,3:PRINT"X",
3170 DEF FNX(X,Y,Z,A,B,C,DT)=X+(-Y-Z)*DT
3180 DEF FNY(X,Y,Z,A,B,C,DT)=Y+(X+A*Y)*DT
3190 DEF FNZ(X,Y,Z,A,B,C,DT)=Z+(B*X-C*Z+X*Z)*DT
3200 '
3210 LOCATE 1,20
3220 PRINT"初期 X=";X;" Y=";Y;" Z=";Z;" DT=";DT;" A=";A;" B=";B;" C=";C
3230 WHILE 1
3240 LOCATE 1,21:PRINT"現在 X=";X;" "
3250 LOCATE 20,21:PRINT" Y=";Y;" "
3260 LOCATE 35,21:PRINT" Z=";Z;" "
3270 LOCATE 1,22:PRINT" DT=";DT;" A=";A;" B=";B;" C=";C;" "
3280 U(0)=Y:U(1)=Z:T=T+1
3290 FOR I=0 TO 1
3300 WINDOW(W(I,0),W(I,1))-(W(I,2),W(I,3))
3310 VIEW(V(I,0),V(I,1))-(V(I,2),V(I,3))
3320 IF Z<30 THEN PSET(U(I),-X),2 ELSE BEEP:ERASE U,V,W:GOTO 3040
3330 NEXT I
3340 XX=FNX(X,Y,Z,A,B,C,DT)
3350 YY=FNY(X,Y,Z,A,B,C,DT)
3360 ZZ=FNZ(X,Y,Z,A,B,C,DT)
3370 X=XX:Y=YY:Z=ZZ
3380 WEND
3390 DATA -15,-15,15,15,10,50,309,349
3400 DATA -5,-15,30,15,330,50,629,349
3410 '
3420 *PRO7
3430 SCREEN@ 0:S=2:COLOR 6,2,0,4:CLS:KEY(6) ON
3440 WINDOW(0,0)-(639,479):VIEW(0,0)-(639,479)
3450 '
3460 ' % % % % % DUFFING MODEL % % % % %
3470 '
3480 LOCATE 0,0:PRINT"初期:変数変更"
3490 X=-.682!:Y=.747!:Z=1.362!:DT=.01!:T=0:B=.25!:B0=.03!:K1=.05!:K2=.05!
3500 P=3.14159!
3510 DIM V(1,3),W(1,3),U(1):RESTORE 3880
3520 FOR I=0 TO 1
3530 FOR J=0 TO 3:READ W(I,J):NEXT J
3540 FOR J=0 TO 3:READ V(I,J):NEXT J
3550 WINDOW(W(I,0),W(I,1))-(W(I,2),W(I,3))
3560 VIEW(V(I,0),V(I,1))-(V(I,2),V(I,3))
3570 LINE(-200,-200)-(200,200),PSET,1,BF
3580 LINE(-200,0)-(200,0),PSET,4:LINE(1,-200)-(1,200),PSET,4
3590 NEXT I
3600 LOCATE 37,10:PRINT"X",:LOCATE 29,3:PRINT"Y",
3610 LOCATE 77,10:PRINT"Z",:LOCATE 50,3:PRINT"Y",
3620 DEF FNX(X,Y,Z,B,B0,K1,K2,DT,TA)=X+Y*DT
3630 DEF FNY(X,Y,Z,B,K1,DT,TA)=Y+(-K1*Y-(X*X+3*Z*Z)*X/8+B*COS(TA))*DT
3640 DEF FNZ(X,Y,Z,B,B0,K1,K2,DT,TA)=Z+(-K2*(3*X*X+Z*Z)*Z/8+B0)*DT
3650 '
3660 LOCATE 1,20
3670 PRINT"初期 X=";X;" Y=";Y;" Z=";Z;" DT=";DT;
3680 PRINT" B=";B;" B0=";B0;" K1=";K1;" K2=";K2
3690 WHILE 1
3700 LOCATE 1,21:PRINT"現在 X=";X;" "
3710 LOCATE 20,21:PRINT" Y=";Y;" "
3720 LOCATE 35,21:PRINT" Z=";Z;" "
3730 LOCATE 1,22:PRINT" DT=";DT;" B=";B;" B0=";B0;
3740 PRINT" K1=";K1;" K2=";K2;" T=";T;" "
3750 U(0)=X:U(1)=Z
3760 FOR I=0 TO 1
3770 WINDOW(W(I,0),W(I,1))-(W(I,2),W(I,3))
3780 VIEW(V(I,0),V(I,1))-(V(I,2),V(I,3))
3790 IF Z<.5! THEN BEEP:ERASE U,V,W:GOTO 3490
3800 'IF TA=0 OR TA=.5!*P OR TA=P OR TA=1.5!*P ELSE GOTO 3850
3810 PSET(U(I),Y),2+T/90 MOD 4
3820 NEXT I
3830 XX=FNX(X,Y,Z,B,B0,K1,K2,DT,TA)
3840 YY=FNY(X,Y,Z,B,K1,DT,TA)
3850 ZZ=FNZ(X,Y,Z,B,B0,K1,K2,DT,TA)
3860 X=XX:Y=YY:Z=ZZ:TA=P*T/180:T=T+1:T=T MOD 360
3870 WEND
3880 DATA -3,-1.5,2,1.5,10,50,309,349
3890 DATA .8,-1.5,2,1.5,330,50,629,349
3900 '
3910 *PRO8
3920 SCREEN@ 0:S=2:COLOR 6,2,0,4:CLS:KEY(6) ON
3930 WINDOW(0,0)-(639,479):VIEW(0,0)-(639,479)
3940 '
3950 ' % % % % % Nonlinear Oscillations % % % % %
3960 '
3970 LOCATE 0,0:PRINT"初期:変数変更"
3980 X=0:Y=-.1!:Z=.25!:DT=.02!:T=360:B=.25!:B0=.24!:K1=.05!:K2=.05!
3990 P=3.14159!
4000 DIM V(1,3),W(1,3),U(1):RESTORE 4370
4010 FOR I=0 TO 1
4020 FOR J=0 TO 3:READ W(I,J):NEXT J
4030 FOR J=0 TO 3:READ V(I,J):NEXT J
4040 WINDOW(W(I,0),W(I,1))-(W(I,2),W(I,3))
4050 VIEW(V(I,0),V(I,1))-(V(I,2),V(I,3))
4060 LINE(-200,-200)-(200,200),PSET,1,BF
4070 LINE(-200,0)-(200,0),PSET,4:LINE(0,-200)-(0,200),PSET,4
4080 NEXT I
4090 LOCATE 37,10:PRINT"X",:LOCATE 21,3:PRINT"Y",
4100 LOCATE 77,10:PRINT"Z",:LOCATE 45,3:PRINT"Y",
4110 DEF FNX(X,Y,Z,B,B0,K1,K2,DT,TA)=X+Y*DT
4120 DEF FNY(X,Y,Z,B,B0,K1,K2,DT,TA)=Y+(-K2*Y-(X*X+3*Z*Z)*X)*DT
4130 DEF FNZ(X,Y,Z,B,B0,K1,DT,TA)=Z+(-K1*((3*X*X+Z*Z)*Z-B0)+B*SIN(TA))*DT
4140 '
4150 LOCATE 1,20
4160 PRINT"初期 X=";X;" Y=";Y;" Z=";Z;" DT=";DT;
4170 PRINT" B=";B;" B0=";B0;" K1=";K1;" K2=";K2
4180 WHILE 1
4190 LOCATE 1,21:PRINT"現在 X=";X;" "
4200 LOCATE 20,21:PRINT" Y=";Y;" "
4210 LOCATE 35,21:PRINT" Z=";Z;" "
4220 LOCATE 1,22:PRINT" DT=";DT;" B=";B;" B0=";B0;
4230 PRINT" K1=";K1;" K2=";K2;" T=";T;" "
4240 U(0)=X:U(1)=Z
4250 FOR I=0 TO 1
4260 WINDOW(W(I,0),W(I,1))-(W(I,2),W(I,3))
4270 VIEW(V(I,0),V(I,1))-(V(I,2),V(I,3))
4280 IF Y>.8!THEN BEEP:ERASE U,V,W:GOTO 3980
4290 'IF TA=0 OR TA=.5!*P OR TA=P OR TA=1.5!*P ELSE GOTO 4340
4300 PSET(U(I),Y),2+T/90 MOD 4
4310 NEXT I
4320 XX=FNX(X,Y,Z,B,B0,K1,K2,DT,TA)
4330 YY=FNY(X,Y,Z,B,B0,K1,K2,DT,TA)
4340 ZZ=FNZ(X,Y,Z,B,B0,K1,DT,TA)
4350 X=XX:Y=YY:Z=ZZ:TA=P*T/180:T=T+1:T=T MOD 360
4360 WEND
4370 DATA -.9,-.6,.6,.8,10,50,309,349
4380 DATA -.1,-.6,1,.8,330,50,629,349
4390 '