|
RESTORE 1 !'この行番号を直接書き換えてください
READ NN
DIM X(NN),Y(NN),S(NN),R(NN),L(NN)
FOR I=1 TO NN
READ X(I),Y(I) !'座標データ 始点(0,0)から終点(1,0)へ
NEXT I
READ XS,XE,YS,YE !'WINDOW設定
FOR I=1 TO NN-1
READ S(I) !'符号反転(1 or -1)
NEXT I
1 DATA 5
DATA 0,0, .333333,0, .5,.288675134594813, .666666,0, 1,0 !'コッホ曲線
DATA -.1,1.1,-.6,.6
!'DATA 1,1,1,1
DATA 1,-1,1,-1 ! '変形コッホ
!'DATA 1,-1,-1,1 '変形コッホ
!'DATA 1,1,-1,-1 '変形コッホ
!'----------------------------------------------------------
2 DATA 3
DATA 0,0,.5,.5,1,0 !'C曲線
DATA -.5,1.5,-1,1
DATA 1,1 !'C曲線
!'DATA 1,-1 !'ドラゴン曲線
!'----------------------------------------------------------
3 DATA 6
DATA 0,0, .33333,0, .33333,.33333, .66666,.33333, .66666,0, 1,0
DATA -.1,1.1,-.6,.6
!'DATA 1,1,1,1,1
DATA 1,-1,1,-1,1
!'DATA 1,1,-1,1,1
!'----------------------------------------------------------
!'ここにDATA文を追加してください
!'----------------------------------------------------------
FOR I=1 TO NN-1
LET R(I)=ANGLE(X(I+1)-X(I),Y(I+1)-Y(I))-RR
LET RR=RR+R(I)
LET L(I)=SQR((X(I)-X(I+1))^2+(Y(I+1)-Y(I))^2)
NEXT I
IF MOD(RR,2*PI)<>0 THEN LET R(NN)=-RR
!' 再帰図形プログラムの書き出し
PRINT "PUBLIC NUMERIC X,Y,R"
PRINT "SET WINDOW ";XS;",";XE;",";YE;",";YS
PRINT "SET POINT STYLE 1"
PRINT "SET COLOR MODE ";CHR$(34);"REGULAR";CHR$(34)
PRINT "DRAW GRID(.1,.1)"
PRINT "INPUT PROMPT ";CHR$(34);"LEVEL=";CHR$(34);": N"
PRINT "CALL RECURSIVE(N,1,1)"
PRINT "END"
PRINT
PRINT "EXTERNAL SUB RECURSIVE(LEV,L,SIGN)"
PRINT "IF LEV=0 THEN"
PRINT "PLOT LINES: X,Y;"
PRINT "LET X=X+L*COS(RAD(R))"
PRINT "LET Y=Y-L*SIN(RAD(R))"
PRINT "PLOT LINES: X,Y"
PRINT "ELSE"
FOR I=1 TO NN-1
IF R(I)<>0 THEN
IF R(I)>0 THEN PRINT "R=R+"; ELSE PRINT "R=R-";
PRINT STR$(ABS(DEG(R(I))));"*SIGN"
END IF
PRINT "CALL RECURSIVE(LEV-1,L*";STR$(L(I));",";STR$(S(I));")"
NEXT I
IF R(NN)<>0 THEN
IF R(NN)>0 THEN PRINT "R=R+"; ELSE PRINT "R=R-";
PRINT STR$(ABS(DEG(R(NN))));"*SIGN"
END IF
PRINT "END IF"
PRINT "END SUB"
END
|
|