|
ペジエ曲線
!'TT=1-T
!'(TT+T)^(N-1) N=点の数 (0 <= T <= 1)
CALL GINIT(640,400)
RANDOMIZE
INPUT PROMPT "点の数 =": N !' N > 1
DIM X(N), Y(N)
FOR I = 1 TO N
LET X(I) = INT(RND * 640)
LET Y(I) = INT(RND * 400)
CALL CIRCLEFULL (X(I),Y(I),6,I)
NEXT I
FOR T = 0 TO 1 STEP 1 / 256
LET XX = 0
LET YY = 0
LET TT=(1-T)
SELECT CASE N
CASE 2
LET XX = TT*X(1)+T*X(2)
LET YY = TT*Y(1)+T*Y(2)
CASE 3
LET XX = TT^2*X(1)+2*TT*T*X(2)+T^2*X(3)
LET YY = TT^2*Y(1)+2*TT*T*Y(2)+T^2*Y(3)
!'CASE 4
!' LET XX = TT^3*X(1)+3*TT^2*T*X(2)+3*TT*T^2*X(3)+T^3*X(4)
!' LET YY = TT^3*Y(1)+3*TT^2*T*Y(2)+3*TT*T^2*Y(3)+T^3*Y(4)
!'CASE 5
!' LET XX = TT^4*X(1)+4*TT^3*T*X(2)+6*TT^2*T^2*X(3)+4*TT*T^3*X(4)+T^4*X(5)
!' LET YY = TT^4*Y(1)+4*TT^3*T*Y(2)+6*TT^2*T^2*Y(3)+4*TT*T^3*Y(4)+T^4*Y(5)
CASE ELSE
FOR I=1 TO N
LET XX=XX+TT^(N-I)*T^(I-1)*X(I)*COMB(N-1,I-1)
LET YY=YY+TT^(N-I)*T^(I-1)*Y(I)*COMB(N-1,I-1)
NEXT I
END SELECT
IF T = 0 THEN
LET XA=XX
LET YA=YY
END IF
CALL LINE(XA,YA,XX,YY,7)
LET XA=XX
LET YA=YY
NEXT T
IF N=4 THEN
SET COLOR 1
PLOT BEZIER: X(1), Y(1) ; X(2), Y(2) ; X(3), Y(3); X(4), Y(4) !'ラインが一致する
END IF
END
EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0 , XSIZE-1 , YSIZE-1, 0
SET POINT STYLE 1
SET COLOR MIX(0) 0,0,0
SET COLOR MIX(1) 0,0,1
SET COLOR MIX(2) 1,0,0
SET COLOR MIX(3) 1,0,1
SET COLOR MIX(4) 0,1,0
SET COLOR MIX(5) 0,1,1
SET COLOR MIX(6) 1,1,0
SET COLOR MIX(7) 1,1,1
CLEAR
END SUB
EXTERNAL SUB LINE(XS,YS,XE,YE,C)
SET COLOR C
PLOT LINES: XS,YS;XE,YE
END SUB
EXTERNAL SUB CIRCLEFULL (X0, Y0, R, C)
LET X = R
LET D = X
LET Y = 0
DO WHILE X >= Y
CALL LINE (X0 - X, Y0 + Y,X0 + X, Y0 + Y, C)
CALL LINE (X0 - X, Y0 - Y,X0 + X, Y0 - Y, C)
CALL LINE (X0 - Y, Y0 + X,X0 + Y, Y0 + X, C)
CALL LINE (X0 - Y, Y0 - X,X0 + Y, Y0 - X, C)
LET D = D - 2 * Y + 1
LET Y = Y + 1
IF D < 0 THEN
LET D = D + 2 * X - 2
LET X = X - 1
END IF
LOOP
END SUB
|
|