|
クヌース曲線(Knuth curve)
https://codom.hatenablog.com/entry/2017/01/20/225952
PUBLIC NUMERIC X,Y,ALPHA
LET XSIZE=650
LET YSIZE=650
CALL GINIT(XSIZE,YSIZE)
INPUT PROMPT "LEVEL(1-10)=":LEV
LET Y=YSIZE-10
IF MOD(LEV,2)=1 THEN
CALL LT(180)
LET X=XSIZE-5
ELSE
CALL LT(90)
LET X=5
END IF
LET L=10*SQR(2)^(9-LEV)
CALL KNUTH(LEV,-90,45,L)
END
EXTERNAL SUB KNUTH(N,A,T,H)
IF N=0 THEN
CALL RT(45+T)
CALL FD(H)
CALL LT(45+T)
ELSE
CALL RT(2*T+A)
CALL KNUTH(N-1,2*T,-T,H)
CALL RT(45-3*T-A)
CALL FD(H)
CALL LT(45-T+A)
CALL KNUTH(N-1,0,-T,H)
CALL RT(A)
END IF
END SUB
EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0,XSIZE-1,YSIZE-1,0
SET POINT STYLE 1
SET COLOR MODE "REGULAR"
FOR I=0 TO 7
SET COLOR MIX(I) BITAND(I,2)/2,BITAND(I,4)/4,BITAND(I,1)
NEXT I
CLEAR
SET COLOR 7
END SUB
EXTERNAL SUB FD(L)
PLOT LINES:X,Y;
LET X=X+L*COS(ALPHA*PI/180)
LET Y=Y-L*SIN(ALPHA*PI/180)
PLOT LINES:X,Y;
END SUB
EXTERNAL SUB LT(R)
LET ALPHA=MOD(ALPHA+R+360,360)
END SUB
EXTERNAL SUB RT(R)
LET ALPHA=MOD(ALPHA-R+360,360)
END SUB
|
|