|
!
! 液体万華鏡
!
! 錯視が、生じ難いよう1回転毎に、逆回転させるようにした。
! 液面の変化に伴う容積変動を、±3.85% 以下まで押えた。
!-----------------
!※正確な液面には、なっていません。改造歓迎。
SET TEXT BACKGROUND "OPAQUE"
SET WINDOW -1/4,1/4, -1/4,1/4
DIM x(2),y(2)
!中心(1/2,1/sqr(3)/2)、半径 r の円周上の点(x0(θ),y0(θ))
DEF x0(θ)=r*COS(θ)+1/2
DEF y0(θ)=r*SIN(θ)+1/SQR(3)/2
!中心(1/2,1/sqr(3)/2)、半径 r の円周上の点(x0(θ),y0(θ))、に接する直線
DEF f(x)=TAN(θ+PI/2)*(x-x0(θ))+y0(θ)
!_直線1とf(x)との交点(x1,y1)
!y=0 =TAN(θ+PI/2)*(x-x0(θ))+y0(θ)
DEF x1(θ)= -y0(θ)/TAN(θ+PI/2)+x0(θ)
LET y1=0
!/直線2とf(x)との交点(x2,y2)
!y=SQR(3)*x =TAN(θ+PI/2)*(x-x0(θ))+y0(θ)
DEF x2(θ)=(-y0(θ)+TAN(θ+PI/2)*x0(θ))/(TAN(θ+PI/2)-SQR(3))
DEF y2(θ)=SQR(3)*x2(θ)
!\直線3とf(x)との交点(x3,y3)
!y=-SQR(3)*(x-1) =TAN(θ+PI/2)*(x-x0(θ))+y0(θ)
DEF x3(θ)=(SQR(3)-y0(θ)+TAN(θ+PI/2)*x0(θ))/(TAN(θ+PI/2)+SQR(3))
DEF y3(θ)=-SQR(3)*(x3(θ)-1)
SET AREA COLOR 5
LET s00=SQR(3)/4
LET φ=0.001
LET stp=PI/180
DO
IF 2*PI<=ABS(φ) THEN LET stp=-stp ! (+)左回転 (-)右回転
LET φ=REMAINDER(φ, 2*PI) +stp
!-----
LET θ=φ+SIN(φ*51)*0.1+SIN(φ*49)*0.05 ! 水面揺れ..有り
!LET θ=φ ! 水面揺れ..無し
!-----
LET r=0.19985-0.00355*COS(θ*6) ! 液面補正、残誤差±3.85%
LET x00=0
LET y00=0
LET i=1
LET x(i)=x1(θ)
LET y(i)=y1
IF 0<=x(i) AND x(i)<=1 AND 0<=y(i) AND y(i)<=SQR(3)/2 THEN LET i=i+1
LET x(i)=x2(θ)
LET y(i)=y2(θ)
IF 0<=x(i) AND x(i)<=1 AND 0<=y(i) AND y(i)<=SQR(3)/2 THEN LET i=i+1.01
IF i< 3 THEN
LET x(i)=x3(θ)
LET y(i)=y3(θ)
IF 2< i THEN
LET x00=1/2
LET y00=SQR(3)/2
ELSE
LET x00=1
LET y00=0
END IF
END IF
LET ss2=ABS((x(1)-x00)*(y(2)-y00)-(y(1)-y00)*(x(2)-x00))
SET DRAW mode hidden
CLEAR
DRAW D4(3) WITH SHIFT(-1/2,-1/SQR(3)/2)*ROTATE(φ-PI/2)
DRAW center WITH SHIFT(-1/2,-1/SQR(3)/2)*ROTATE(-φ-PI/2)*SCALE(-1/8,1/8)
PLOT TEXT,AT 0.13,0.23:"右クリックで終了"
SET DRAW mode explicit
WAIT DELAY 0.05
MOUSE POLL mx,my,mlb,mrb
LOOP UNTIL mrb>=1
PICTURE center
SET LINE COLOR 2
SET LINE width 2
PLOT LINES:0,0;1,0;1/2,SQR(3)/2;0,0
SET LINE width 1
SET LINE COLOR 1
END PICTURE
!------
PICTURE D4(k)
IF 0< k THEN
DRAW D4(k-1) WITH SCALE(1/2,1/2)*SHIFT(1/4,SQR(3)/4) ! 上
DRAW D4(k-1) WITH SCALE(1/2,-1/2)*SHIFT(1/4,SQR(3)/4) ! 中
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(-PI*2/3)*SHIFT(1/4,SQR(3)/4) !左
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(PI*2/3)*SHIFT(1,0) ! 右
ELSE
DRAW Set01
END IF
END PICTURE
!------ 種の三角図
PICTURE Set01
IF s00< ss2 THEN
IF x00=0 THEN PLOT AREA:x(1),y(1);x(2),y(2);1/2,SQR(3)/2;1,0
IF x00=1 THEN PLOT AREA:x(1),y(1);x(2),y(2);1/2,SQR(3)/2;0,0
IF x00=1/2 THEN PLOT AREA:x(1),y(1);x(2),y(2);1,0;0,0
ELSE
PLOT AREA:x(1),y(1);x(2),y(2);x00,y00
END IF
PLOT LINES:x(1),y(1);x(2),y(2)
PLOT LINES:0,0;1,0;1/2,SQR(3)/2;0,0
END PICTURE
END
|
|