Tikz,两个圆之间的切线

Tikz,两个圆之间的切线

我正在尝试创建下面的图像

在此处输入图片描述

这是我的代码

\documentclass[10pt,a4paper]{article}
\usepackage{tikz,tkz-euclide}

\begin{document}
\center
\begin{tikzpicture}
\tkzDefPoint(0,0){O}
\tkzDefPoint(0,1.25){A1}
\tkzDefPoint(0,3){A2}
\tkzDefPoint(3,0){A3}
\tkzDrawCircle[very thick,color=blue,fill=green!80!black,opacity=0.6](O,A2)
\tkzDrawCircle[fill=white](O,A1)
\end{tikzpicture}

\end{document}

我的问题是,如何创建切线?有没有比我更有效的方法?=)

答案1

如果切线是水平的,则不需要三角函数,并且可以进行以下操作。

\begin{tikzpicture}
\draw[thick,fill=green!20] (0,0) circle (2cm);
\path[clip] (0,0) circle (2cm);
\fill[green!30] (0,0) circle (2cm);
\draw[thick,blue,fill=white] (0,0) circle (1cm);
\draw[thick,red] (-2,1) -- (2,1) node[midway,above,black] {A};
\end{tikzpicture}

请注意,这非常简单,仅用于生成您想要的图像。还有更复杂的方法(请参阅 Jake 的回答),但我经常默认使用这种快速而粗糙的方法,因为尽管我喜欢制作图表,但时间就是金钱!

在此处输入图片描述

答案2

您可以使用\tkzDefPointWith[orthogonal](A1,O)找到过 的切线上的一点A1,然后使用该新点和\tkzInterLC找到切线与外圆之间的交点。

我对圆圈的定义有些不同:

\documentclass[border=5mm]{standalone}

\usepackage{tkz-euclide}
\usetkzobj{all}

\begin{document}

\begin{tikzpicture}
\tkzDefPoint(0,0){O} % centre
\tkzDefPoint(90:1){A} % defines small radius and tangent point
\tkzDefPoint(90:2){B} % defines large radius
\tkzDrawCircle(O,A)
\tkzDrawCircle(O,B)

\tkzDefPointWith[orthogonal](A,O) \tkzGetPoint{Q} % find a point Q orthogonal to AO
\tkzInterLC(A,Q)(O,B) \tkzGetPoints{A'}{A''} % find intersections of a line passing through A and Q with the large circle 
\tkzDrawSegment(A',A'') % draw the tangent
\tkzDrawPoints(A,A',A'') % show the points
\tkzLabelPoints[above](A)
\end{tikzpicture}
%
\end{document}

当然,这也可以通过内置的 TikZ 机制(即intersections库)来实现。与裁剪方法相比,这种方法的优点是可以使切线的端点可用。通过使用($(<point>)!<factor>!<angle>:(<point>)$)定义切线的语法,您可以使用任意切点(如inner.37)。

\documentclass[border=5mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc, intersections}

\begin{document}

\begin{tikzpicture}
\node (inner) [draw, circle, minimum size=2cm] {}; % draw the small circle
\node (outer) [draw, circle, minimum size=4cm, name path=outer] {}; % draw the large circle, name the path for finding the intersections later
\coordinate (O) at (0,0); % name the origin
\coordinate [label=A] (A) at (inner.90)  {}; % name the tangent point on the small circle

\begin{pgfinterruptboundingbox} % do not update the bounding box
\path [name path global=tangent] ($(A)!-10!90:(O)$) -- ($(A)!10!90:(O)$); % define the tangent path, make it long (20 times the radius of the small circle) to catch all intersections
\end{pgfinterruptboundingbox}

\draw [name intersections={of=outer and tangent}] (intersection-1) -- (intersection-2);
\filldraw [fill=gray] (intersection-1) circle [radius=1pt] (intersection-2) circle [radius=1pt];
\end{tikzpicture}
%
\end{document}

答案3

只是为了和 PSTricks 一起玩。

在此处输入图片描述

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}[showgrid=bottom](-3,-3)(3,3)
    \psclip{\pscustom[fillcolor=green,fillstyle=eofill]{\pscircle{3}\moveto(2,0)\pscircle{2}}}
        \psline[linecolor=red](-3,2)(3,2)
    \endpsclip
    \uput{2pt}[90](0,2){$A$}
\end{pspicture}
\end{document}

动画版:

在此处输入图片描述

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{multido}
\begin{document}
\multido{\n=0.0+0.1}{21}{%
\begin{pspicture}[showgrid=bottom](-3,-3)(3,3)
    \psclip{\pscustom[fillcolor=green,fillstyle=eofill]{\pscircle{3}\moveto(\n,0)\pscircle{\n}}}
        \psline[linecolor=red](-3,\n)(3,\n)
    \endpsclip
    \uput{2pt}[90](0,\n){$A$}
\end{pspicture}}
\end{document}

答案4

只是为了好玩:

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{multido}\SpecialCoor
\begin{document}
\multido{\n=0.0+0.1,\iB=0+18}{21}{%
\begin{pspicture}[showgrid=bottom](-3,-3)(3,3)
  \psclip{\pscustom[fillcolor=green,fillstyle=eofill]{\pscircle{3}\moveto(\n,0)\pscircle{\n}}}
    \rput{\iB}(\n;\iB){%
       \psline[linecolor=red,linewidth=2pt](-5,\n)(3,\n)
       \psdot(-\n,\n)\uput{2pt}[90]{\iB}(-\n,\n){\Large A}}
    \endpsclip
\end{pspicture}}
\end{document}

在此处输入图片描述

相关内容