我想要制作以下图形。
这是我的起始代码。
\documentclass[12pt,a4paper]{article}
\usepackage{tkz-euclide}
\usetikzlibrary{arrows.meta}
\usetkzobj{all}
\begin{document}
\Huge
\begin{tikzpicture}[scale=.8,> = {Stealth[length=10pt, inset=5pt]}]
\tkzDefPoint(0,0){Origin}
\tkzDefPoint(12,0){O}
\pgfmathsetmacro{\Radius}{4}
\tkzTangent[from with R = O](Origin,\Radius cm) \tkzGetPoints{R}{I}
\tkzDrawCircle[R](Origin,\Radius cm)
\tkzDrawSegments[->,thick,black,add = 0 and .4](O,R O,I)
\tkzDrawSegments[thick,red](Origin,R Origin,I)
\tkzLabelPoints[left,above](R)
\tkzLabelPoints[left,below](I)
\tkzLabelPoints[right](O)
\tkzLabelPoint[left](Origin){$P$}
\end{tikzpicture}
\end{document}
我错过了什么?
答案1
另一个 (简短的) 使用 PSTricks。用 运行lualatex
。
\RequirePackage{pdfmanagement-testphase}% For opacity
\DocumentMetadata{}
\documentclass[pstricks, border=6pt, svgnames]{standalone}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}(-6.5,-3)(3,3)
\pstGeonode[PosAngle={0,180}](0,0){O}(-6,0){T}
\pscircle(O){2}
\psCircleTangents(T)(O){2}
\pspolygon[fillcolor=red!30,fillstyle=solid,opacity=0.75](T)(CircleT1)(O)
\pspolygon[fillcolor=blue!30,fillstyle=solid,opacity=0.75](T)(CircleT2)(O)
\pstRightAngle{T}{CircleT1}{O}\pstRightAngle{T}{CircleT2}{O}
\pstSegmentMark{T}{CircleT1} \pstSegmentMark{T}{CircleT2}
\psset{SegmentSymbol=pstslash}\pstSegmentMark{O}{CircleT1} \pstSegmentMark{O}{CircleT2}
\uput[-80](CircleT1){$A$}\uput[80](CircleT2){$B$}
\end{pspicture}
\end{document}
答案2
以下是获取图形的一种方法pstricks
:
\documentclass[pstricks, border=6pt, svgnames]{standalone}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}(-6.5,-3)(3,3)
\psset{PointSymbol=none, linejoin=1}
\pnode(2,0){M}
\pstGeonode[PosAngle={0,180}](0,0){O}(-6,0){T}
\pstCircleTangentNode[PosAngle={120,-120}, linewidth=0pt]{O}{M}{T}{A}{B}
\psset{linecolor=IndianRed, fillstyle=solid}
\pspolygon[fillcolor=AliceBlue!65!Lavender](T)(O)(A)
\pspolygon[fillcolor=Yellow](T)(O)(B)
\pstLineAB[nodesepB=-2]{T}{A} \pstLineAB[nodesepB=-2]{T}{B}
\pstSegmentMark{T}{A} \pstSegmentMark{T}{B}
\psset{SegmentSymbol=pstslash}\pstSegmentMark{O}{A} \pstSegmentMark{O}{B}
\psset{linecolor=black, fillstyle=none}
\pstCircleOA{O}{M}[20][340]
\pstRightAngle{T}{A}{O}\pstRightAngle{T}{B}{O}
\end{pspicture}
\end{document}
答案3
这是 lkast 版本 4.25 的解决方案
\documentclass[border=1cm]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}
\tkzDefPoints{0/0/D,12/0/O,16/0/C}
\tkzDefLine[tangent from = D](O,C)% with 4.25
\tkzGetPoints{A}{B}
% all the points are known it is now enough to draw, to place the labels
\tkzDrawCircle(O,C)
\tkzDrawPolygons[red](D,O,A D,O,B)
\tkzMarkSegments[mark=s||,red](A,D B,D)
\tkzMarkSegments[mark=s|](A,O B,O)
\tkzMarkRightAngles(D,A,O O,B,D)
\tkzDrawPoints(A,B,O,D)
\tkzFillPolygon[gray!40,opacity=.4](D,A,O)
\tkzFillPolygon[yellow!40,opacity=.4](D,B,O)
\tkzLabelPoints[above](A)
\tkzLabelPoints[below](B)
\tkzLabelPoints[left](D)
\tkzLabelPoints[right](O)
\end{tikzpicture}
\end{document}
答案4
为了进行比较,以下是使用原始 TikZ 和库进行的绘图
calc
为了tangent cs
,through
钥匙circle through
和angles
为了right angle
图片。
该backgrounds
库定义了一个图层,background
我们可以与pgfonlayer
环境一起使用它在圆圈后面绘制三角形。
代码
\documentclass[12pt,tikz,convert]{standalone}
\usepackage[T1]{fontenc}
\usetikzlibrary{
backgrounds, % for background layer
calc, % for tangent cs
through, % for circle through
angles % for right angle pic
}
\begin{document}
\begin{tikzpicture}[
thick, shorten/.style={shorten <={#1}, shorten >={#1}},
circle at/.style args={#1)#2radius#3}{
at={#1)}, circle through={([shift={#1)}]0:#3)}, node contents=},
l/.style args={#1:#2}{label={#1:$#2$}},
mark line/.style={edge node={node[sloped,midway]{\textbf{#1}}}}
]
\coordinate[l=left:T] (T) at (0, 0)
coordinate[l=right:O] (O) at (12,0);
\node (c) [circle at=(O) radius 4, draw];
\foreach \d/\n/\s in {above left/A/2, below left/B/1}
\coordinate[l=\d:\n] (\n) at (tangent cs: point={(T)}, node=c, solution=\s);
\begin{pgfonlayer}{background}
\foreach \p/\c in {A/blue!20, B/yellow!20}
\draw[red, thick, fill=\c, line join=round]
(O) to[mark line=|] (\p) to[mark line=||] coordinate[pos=-.3] (\p\p)
(T) -- cycle (\p) -- (\p\p)
pic[draw=black, shorten=.5\pgflinewidth]{right angle=T--\p--O};
\end{pgfonlayer}
\foreach \p in {A, B, O, T} \fill(\p) circle[radius=1.5pt];
\end{tikzpicture}
\end{document}