|
!-------------------------------------------
! http://www.sansu.org/
!第1120回問題(1月16日~ 1月24日)
!
! ∠ADC=90°、AB=9cm の四角形ABCD
! 対角線ACをひくと、∠BAC=70°、∠DAC=55°
! 辺BCの中点Mと頂点Dを結んだところ、DM=8cm
! 対角線ACの長さは何cm?
!-------------------------------------------
OPTION ARITHMETIC COMPLEX
SET WINDOW -2,12, -3,11
SET TEXT background "opaque"
SET POINT COLOR "red"
SET POINT STYLE 7
!--
LET B=0
LET aa=PI/3
LET act=-50
SUB calc
LET A=9*EXP(COMPLEX(0,aa))
LET C=intsec2(B,A,10,(B-A)*EXP(COMPLEX(0,PI*70/180))+A)
LET M=(B+C)/2
LET ww=(C-A)*EXP(COMPLEX(0,PI*55/180))
LET D=intsec2(A,C,ww+A,ww*COMPLEX(0,1)+C)
LET AC=ABS(A-C)
LET DM=ABS(D-M)
IF i$="" THEN
LET aa=aa-(DM-8)*.1
END IF
END SUB
SUB draw00
SET DRAW mode hidden
CLEAR
DRAW grid
!--
SET LINE COLOR "blue"
CALL rect_m3(A,D,.5)
PLOT TEXT,AT arc2(B,A,C,.8)+COMPLEX(-.3,-.53) :"70°"
PLOT TEXT,AT arc2(C,A,D,.7)+COMPLEX( 0,-.5 ) :"55°"
SET LINE COLOR "black"
PLOT LINES: A;B;C;D;A;C
PLOT LINES: M;D
PLOT POINTS: (B+M)/2; (M+C)/2
!--
PLOT TEXT,AT A+COMPLEX( 0, 0) :"A"
PLOT TEXT,AT B+COMPLEX(-.3,-.1) :"B"
PLOT TEXT,AT C+COMPLEX( .1,-.1) :"C"
PLOT TEXT,AT D+COMPLEX( 0, 0) :"D"
PLOT TEXT,AT M+COMPLEX( 0,-.5) :"M"
!--
SET LINE STYLE 3
PLOT TEXT,AT arch_(A,B, 1)+COMPLEX( 0, 0) :"9cm"
PLOT TEXT,AT arch_(D,M,.8)+COMPLEX(-.8,-.8) :STR$(ROUND(DM,2))& "cm"
SET LINE STYLE 1
!--
PLOT TEXT,AT COMPLEX(6.2,-1.6) :"AC= "& STR$(AC)& "cm"
IF ABS(DM-8)< 1e-14 THEN PLOT TEXT,AT COMPLEX(6.2,-1.6) :"答えを見るには?" !←消す
!--
PLOT TEXT,AT -.5, 9.5 :"左ボタンで、A点 の旋回(中心B) がドラッグ可。"
PLOT TEXT,AT -.5, 8.9 :"十分離れた 白地の所で、左ボタンを 押し続けると"
PLOT TEXT,AT -.5, 8.3 :"題意に沿う様 自動変形する。 右ボタン終了。"
SET DRAW mode explicit
END SUB
DO
CALL calc
CALL draw00
mouse poll x,y,mlb,mrb
DO WHILE mlb=0 AND mrb=0 AND 0< act
WAIT DELAY .01 !待機中の省電力
mouse poll x,y,mlb,mrb
LET z=COMPLEX(x,y)
LET i$="A"
LET i=ABS(z-A)
IF 1< i THEN LET i$=""
LOOP
IF i$="A" THEN LET aa=ANGLE(x,y)
LET act=act+1
LOOP UNTIL mlb=0 AND mrb=1
!--------------------
! │ 直角の印 (幅w)
! ├┐
! B└┴─A
!--------------------
SUB rect_m3(A,B,w)
local i
IF A<>B THEN
LET i=w*(A-B)/ABS(A-B)
PLOT LINES: B+i; B+i*COMPLEX(1,1); B+i*COMPLEX(0,1)
END IF
END SUB
!-------------------------------------------
! 寸法表示用 弓状の線 (返り値:弓の中腹座標)
! A B B\ /A
! \_/ | |
! A/ B/~\A \B
!-------------------------------------------
FUNCTION arch_(A,B,h) !h=中腹の膨らみ幅
local C,O,r,i,e
LET C=h*(A-B)/ABS(B-A)*COMPLEX(0,1)+(A+B)/2
LET O=fO_(A,B,C)
LET r=ABS(A-O)
LET e=arg(B-O)
IF arg(A-O) > e THEN LET e=e+2*PI
FOR i=arg(A-O) TO e STEP .1/r
PLOT LINES: r*EXP(COMPLEX(0,i))+O;
NEXT i
PLOT LINES: r*EXP(COMPLEX(0,e))+O
LET arch_=C
END FUNCTION
!--------------------------
! 点 A,B,C を通る円の中心 O
!--------------------------
DEF fO_(A,B,C)= intsec2((A-B)*COMPLEX(0,1)+(B+A)/2, (B+C)/2, (B+A)/2, (C-B)*COMPLEX(0,1)+(B+C)/2)
!--------------------------------------------------------------------------
! ∠ABC の AB からBC まで 中心B 半径r の左回転円弧(返り値:円弧の中腹座標)
!--------------------------------------------------------------------------
FUNCTION arc2(A,B,C,r)
local w,s,i
LET w=arg((C-B)/(A-B))
LET s=r*(A-B)/ABS(A-B)
FOR i=0 TO w STEP PI/36
PLOT LINES: s*EXP(COMPLEX(0,i))+B;
NEXT i
PLOT LINES: s*EXP(COMPLEX(0,w))+B
LET arc2=s*EXP(COMPLEX(0,w/2))+B
END FUNCTION
!---------------------------------------------
! A\ /D P 交点 A\ /D
! P 交点 /\ \C B/
! B/ \C /D A\ \/
! B/ \C P 交点
!---------------------------------------------
FUNCTION intsec2(A,B,C,D)
local da,ab
LET da=im((D-A)/(C-A))
LET ab=im((A-B)/(C-A))
LET intsec2= ab/(da+ab)*(D-B)+B
END FUNCTION
END
|
|