KTUG 한국 텍 사용자 그룹

Menu

KTUG :: 마당

.mp파일이 업로드가 않되네요. 컴맹수준이라 여기에 원본 mp파일을 올립니다.

verbatimtex

\input kotexutf.tex

etex;

% In compiling, mpost foo (.mp omitted)

% and mptopdf foo (.mp omitted)

 

beginfig(1)%---------------둔각삼각형----------- refer to YOUTUBER, Michael Penn

u=10mm;

numeric a[],b[],c[],d[], h, k, r, rr;%center(h, k), radii r, rr;

pair A, B, C;

A=(-2, 0); %wlog, A=(-a, 0), B=(a, 0), C=(b, c)

B=(2, 0);

C=(-2.5, 3); %C=(0, 2*sqrt(3)) eqilateral triangle;

a1=xpart A;

a2=ypart A;

b1=xpart B;

b2=ypart B;

c1=xpart C;

c2=ypart C;

 

d1=abs(A-B);

d2=abs(B-C);

d3=abs(C-A);

 

%solve simultaneous eq.

% dist((h, k), mid(A,B))=r-dist(A,B)/2---(1)

% dist((h, k), mid(B,C))=r-dist(B,C)/2---(2)

% dist((h, k), mid(C,A))=r-dist(C,A)/2---(3)

 

numeric adotb, bdotc, cdota;

adotb=a1*b1+a2*b2;

bdotc=b1*c1+b2*c2;

cdota=c1*a1+c2*a2;

 

(a1-c1)*h+(a2-c2)*k-(d1-d2)*r=adotb-bdotc;%(1)-(2)

(b1-a1)*h+(b2-a2)*k-(d2-d3)*r=bdotc-cdota;%(2)-(3)

%get h, k in terms of r and substitute these to one of (1), (2), (3),

%and we have the quadratic eq.(*) with respect to radius r

 

numeric t[], s[];%temporary variables

 

t1=((d1-d2)*(b2-a2)-(d2-d3)*(a2-c2))/((a1-c1)*(b2-a2)-(b1-a1)*(a2-c2));

s1=((adotb-bdotc)*(b2-a2)-(bdotc-cdota)*(a2-c2))/((a1-c1)*(b2-a2)-(b1-a1)*(a2-c2));

 

t2=((d1-d2)*(b1-a1)-(d2-d3)*(a1-c1))/((a2-c2)*(b1-a1)-(b2-a2)*(a1-c1));

s2=((adotb-bdotc)*(b1-a1)-(bdotc-cdota)*(a1-c1))/((a2-c2)*(b1-a1)-(b2-a2)*(a1-c1));

 

numeric l, m, n;%coefficients of quadratic eq. l*r*r + m*r + n = 0 ---- (*)

 

l=t1*t1+t2*t2-1;

m=2*t1*s1+2*t2*s2-(a1+b1)*t1-(a2+b2)*t2+d1;

n=s1*s1+s2*s2-(a1+b1)*s1-(a2+b2)*s2+adotb;

 

r=(0-m+sqrt(m*m-4*l*n))/(2*l);%roots of quadratic eq.(*)

rr=(0-m-sqrt(m*m-4*l*n))/(2*l);

 

 

draw (A--B--C--cycle) scaled u;%---input triangle & circles

draw (fullcircle scaled d1 shifted 0.5[A,B]) scaled u withcolor red;

draw (fullcircle scaled d2 shifted 0.5[B,C]) scaled u withcolor green;

draw (fullcircle scaled d3 shifted 0.5[C,A]) scaled u withcolor blue;

 

h:=t1*rr+s1;

k:=t2*rr+s2;

 

draw (fullcircle scaled (2*rr) shifted (h,k)) scaled u dashed dashpattern(on 2bp off 3bp);%---results

pair P,Q,R;%tangent points

P:=(rr/(rr-0.5*d1))[(h,k), 0.5[A,B]];

Q:=(rr/(rr-0.5*d2))[(h,k), 0.5[B,C]];

R:=(rr/(rr-0.5*d3))[(h,k), 0.5[C,A]];

 

for i=P, Q, R: drawarrow ((h,k)--i) scaled u dashed dashpattern(on 2bp off 3bp); endfor;

 

h:=t1*r+s1;

k:=t2*r+s2;

 

draw (fullcircle scaled (2*r) shifted (h,k)) scaled u dashed dashpattern(on 2bp off 2bp);%---results

P:=(r/(r-0.5*d1))[(h,k), 0.5[A,B]];

Q:=(r/(r-0.5*d2))[(h,k), 0.5[B,C]];

R:=(r/(r-0.5*d3))[(h,k), 0.5[C,A]];

 

for i=P, Q, R: drawarrow ((h,k)--i) scaled u dashed dashpattern(on 2bp off 2bp); endfor;

 

endfig;

 

beginfig(2)%직각삼각형

numeric a[],b[],c[],d[], h, k, r, rr;%center(h, k), radii r, rr;

pair A, B, C;

A=(-2, 0); %wlog, A=(-a, 0), B=(a, 0), C=(b, c)

B=(2, 0);

C=(-2, 3);

a1=xpart A;

a2=ypart A;

b1=xpart B;

b2=ypart B;

c1=xpart C;

c2=ypart C;

 

d1=abs(A-B);

d2=abs(B-C);

d3=abs(C-A);

 

%solve simultaneous eq.

% dist((h, k), mid(A,B))=r-dist(A,B)/2---(1)

% dist((h, k), mid(B,C))=r-dist(B,C)/2---(2)

% dist((h, k), mid(C,A))=r-dist(C,A)/2---(3)

 

numeric adotb, bdotc, cdota;

adotb=a1*b1+a2*b2;

bdotc=b1*c1+b2*c2;

cdota=c1*a1+c2*a2;

 

(a1-c1)*h+(a2-c2)*k-(d1-d2)*r=adotb-bdotc;%(1)-(2)

(b1-a1)*h+(b2-a2)*k-(d2-d3)*r=bdotc-cdota;%(2)-(3)

%get h, k in terms of r and substitute these to one of (1), (2), (3),

%and we have the quadratic eq.(*) with respect to radius r

 

numeric t[], s[];%temporary variables

 

t1=((d1-d2)*(b2-a2)-(d2-d3)*(a2-c2))/((a1-c1)*(b2-a2)-(b1-a1)*(a2-c2));

s1=((adotb-bdotc)*(b2-a2)-(bdotc-cdota)*(a2-c2))/((a1-c1)*(b2-a2)-(b1-a1)*(a2-c2));

 

t2=((d1-d2)*(b1-a1)-(d2-d3)*(a1-c1))/((a2-c2)*(b1-a1)-(b2-a2)*(a1-c1));

s2=((adotb-bdotc)*(b1-a1)-(bdotc-cdota)*(a1-c1))/((a2-c2)*(b1-a1)-(b2-a2)*(a1-c1));

 

numeric l, m, n;%coefficients of quadratic eq. l*r*r + m*r + n = 0 ---- (*)

 

l=t1*t1+t2*t2-1;

m=2*t1*s1+2*t2*s2-(a1+b1)*t1-(a2+b2)*t2+d1;

n=s1*s1+s2*s2-(a1+b1)*s1-(a2+b2)*s2+adotb;

 

r=(0-m+sqrt(m*m-4*l*n))/(2*l);%roots of quadratic eq.(*)

rr=(0-m-sqrt(m*m-4*l*n))/(2*l);

 

 

draw (A--B--C--cycle) scaled u;%---input triangle & circles

draw (fullcircle scaled d1 shifted 0.5[A,B]) scaled u withcolor red;

draw (fullcircle scaled d2 shifted 0.5[B,C]) scaled u withcolor green;

draw (fullcircle scaled d3 shifted 0.5[C,A]) scaled u withcolor blue;

 

h:=t1*rr+s1;

k:=t2*rr+s2;

 

draw (fullcircle scaled (2*rr) shifted (h,k)) scaled u dashed dashpattern(on 2bp off 3bp);%---results

pair P,Q,R;%tangent points

P:=(rr/(rr-0.5*d1))[(h,k), 0.5[A,B]];

Q:=(rr/(rr-0.5*d2))[(h,k), 0.5[B,C]];

R:=(rr/(rr-0.5*d3))[(h,k), 0.5[C,A]];

 

for i=P, Q, R: drawarrow ((h,k)--i) scaled u dashed dashpattern(on 2bp off 3bp); endfor;

 

h:=t1*r+s1;

k:=t2*r+s2;

 

draw (fullcircle scaled (2*r) shifted (h,k)) scaled u dashed dashpattern(on 2bp off 2bp);%---results

P:=(r/(r-0.5*d1))[(h,k), 0.5[A,B]];

Q:=(r/(r-0.5*d2))[(h,k), 0.5[B,C]];

R:=(r/(r-0.5*d3))[(h,k), 0.5[C,A]];

 

for i=P, Q, R: drawarrow ((h,k)--i) scaled u dashed dashpattern(on 2bp off 2bp); endfor;

 

endfig;

end

KTUG 한국 텍 사용자 그룹