绘制一个圆和它的两条切线

绘制一个圆和它的两条切线

我正在尝试在圆的两条切线之间添加一些特征。图片有点“紧凑”。我认为将其放大 2 倍比较合适。这样我也可以把节点 (1,1) 放在圆的中心。在我看来,直线方程的标签放在直线的四分之三处而不是直线的末端会更好看。(如果将圆半径的标签 r 移得更靠近圆,也会更好看。)沿轴在 0.6 和 1.2 处打勾会很有帮助。我在这个网站上看到了如何手动添加它们。一定有一种方法可以使用默认设置添加它们。

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}


\begin{document}

\begin{tikzpicture}
\draw[draw=gray!30,latex-latex] (0,3) +(0,0.5cm) node[above right] {$y$} -- (0,-1) -- +(0,-0.5cm);
\draw[draw=gray!30,latex-latex] (-1,0) +(-0.5cm,0) -- (3,0) -- +(0.5cm,0) node[below right] {$x$};
\draw[blue,domain=-0.5:1.5,samples=2,latex-latex] plot (\x, 2*\x) node[above left, font=\footnotesize]{$y = 2x$};
\draw[blue,domain=-1:3,samples=2,latex-latex] plot (\x, 0.5*\x) node[below right, font=\footnotesize]{$y = \frac{1}{2}x$};
\draw[domain=-1:3,samples=2,dashed,latex-latex] plot (\x, \x) node[right, font=\footnotesize]{$y = x$};
\draw[green] (1,1) circle (0.44721);
\draw [green,fill] (1,1) circle [radius=1.5pt];
\draw[green,-latex] (1,1) -- +(-30:0.44721) node[midway, above, font=\footnotesize]{$r$};
\draw [green,fill] (0.6,1.2) circle [radius=1pt];
\draw [green,fill] (1.2,0.6) circle [radius=1pt];
\draw [fill] (0,0) circle [radius=1.5pt];
\end{tikzpicture}

\end{document}

答案1

我会用pgfplots

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}

\begin{document}

\begin{tikzpicture}[>=latex]
\begin{axis}[xlabel=$x$,ylabel=$y$,axis lines=middle,
axis line style={gray!30,latex-latex},xtick={1},ytick={1},
no marks,axis equal,xmin=-1,xmax=2,ymax=1.5,ymin=-1,enlargelimits={upper=0.1}
]
\draw[thin,gray!30] (1,0) |- (0,1);
\addplot[dashed,domain=-0.8:1.5,<->] {x} node[below right]{$\scriptstyle y = x$};
\addplot[blue,domain=-0.5:0.8,<->] {2*x} node[left,pos=0.95]{$\scriptstyle y = 2x$};
\addplot[blue,domain=-1:2.2,<->] {0.5*x} node[below right=1pt,inner sep=0,pos=0.85] 
                                                   {$\scriptstyle y=\frac{1}{2}x$};

\begin{scope}[green]
\draw (1,1) circle ({sqrt(2)*sin(45-atan(0.5))});
\draw (1,1) -- ({atan(0.5)}:{sqrt(2)*cos(45-atan(0.5))}) node[midway,right]{$r$};
\fill (1,1) circle (1.5pt)
({atan(2)}:{sqrt(2)*cos(45-atan(0.5))}) circle (1.5pt)
({atan(0.5)}:{sqrt(2)*cos(45-atan(0.5))}) circle (1.5pt);
\end{scope}
\end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容