Skip to content

Instantly share code, notes, and snippets.

@dohyunkim
Created May 29, 2014 00:12
Show Gist options
  • Select an option

  • Save dohyunkim/e12fa618f2fd6f9fcdbe to your computer and use it in GitHub Desktop.

Select an option

Save dohyunkim/e12fa618f2fd6f9fcdbe to your computer and use it in GitHub Desktop.
임의의 곡선에 접선 그리기
\documentclass[border=2pt]{standalone}
\usepackage{luatexko}
\usepackage{luamplib}
\mplibtextextlabel{enable}
\begin{document}
\begin{mplibcode}
beginfig(0);
u = 1cm;
rgbcolor juwhang; juwhang = (1, 1/2, 0);
pair a, b, c, d, A[], C[];
path R, X[];
% grid
for i=-1 step 0.5 until 8:
draw (i*u,-1u) -- (i*u,8u) withpen pencircle scaled .2 withcolor .7white;
draw (-1u,i*u) -- (8u,i*u) withpen pencircle scaled .2 withcolor .7white;
endfor
% x, y axis
drawarrow (-.2u, 0) -- (8u, 0); label.bot("$X_d$ (국산)", (8u, 0));
drawarrow (0, -.2u) -- (0, 8u); label.lft("$X_m$ (수입)", (0, 8u));
drawoptions(withpen pencircle scaled 1);
R = (0, 0) -- (5u, 1.3*5u);
draw R; label.rt ("$R$", (5u, 1.3*5u));
a = (.5u, 7.5u);
b = (7.5u, .3u); label.rt ("$X=10$", b);
c = a + (1u, 0);
d = b + (0, 1u); label.rt ("$X=15$", d);
X10 = a .. controls (1u, 2.5u) and (2.5u, 1u) .. b;
draw X10 withcolor red;
X15 = c .. controls (1.5u, 5u) and (4u, 2u) .. d;
draw X15 withcolor blue;
% A: 교점에서 X10의 진행 시간
(A, whatever) = X10 intersectiontimes R;
% A1: 접선의 기울기
A1 = direction A of X10;
% A2: 교점의 좌표
A2 = point A of X10; label.rt ("$A$", A2);
draw (-A1 -- A1) shifted A2 withcolor juwhang;
(C, whatever) = X15 intersectiontimes R;
C1 = direction C of X15;
C2 = point C of X15; label.rt ("$C$", C2);
draw (-C1 -- C1) shifted C2 withcolor juwhang;
endfig;
\end{mplibcode}
\end{document}
@dohyunkim
Copy link
Author

Progress 왈:
C점의 접선이 X=10 곡선을 뚫고 가야해서 남동쪽 선분 길이를 1.5배 해주었습니다.

draw (-C1 -- 1.5*C1) shifted C2 withcolor juwhang;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment