![如何使用 TikZ 构建由半圆组成的封闭、填充的路径并将其附加注释?](https://linux22.com/image/295400/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20TikZ%20%E6%9E%84%E5%BB%BA%E7%94%B1%E5%8D%8A%E5%9C%86%E7%BB%84%E6%88%90%E7%9A%84%E5%B0%81%E9%97%AD%E3%80%81%E5%A1%AB%E5%85%85%E7%9A%84%E8%B7%AF%E5%BE%84%E5%B9%B6%E5%B0%86%E5%85%B6%E9%99%84%E5%8A%A0%E6%B3%A8%E9%87%8A%EF%BC%9F.png)
我对 LaTeX 的了解非常有限。我正在尝试使用“tikz”绘制下图,如果有人能帮助我完成绘制,我将不胜感激。到目前为止,我做了以下事情:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) arc (0:180:6);
\draw (-12,0) - -(0,0);
\draw (-8,0) arc (0:180:2);
\draw (0,0) arc (0:180:4);
\draw (-6,-0.1) - - (-6,0.1);
\end{tikzpicture}
\end{document}
有一个大半圆和两个内部小半圆。我想用“A”标记大半圆的右端点,用“B”标记大半圆的左端点。我想用“O”标记大半圆的中心,用“P”标记两个小半圆相交的点。我还想用阴影标记大半圆内部和两个小半圆外部的区域。我还想在图中指出大圆的半径为:6。点“O”和点“P”之间的距离为“x”
任何帮助深表感谢
答案1
您还可以一次性绘制该路径,这样如果路径下方有其他内容,则无需填充白色来限制填充。同时,您还可以放置标签和坐标。
\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\filldraw[fill=blue] (0,0)
coordinate[label=-90:$B$] (B)
arc (180:0:3cm)
coordinate[label=-90:$A$] (A)
arc (0:180:2cm)
coordinate[label=-90:$P$] (P)
arc (0:180:1cm);
\draw (B)--(A) coordinate[midway,label=-90:$O$] (O);
\draw[decoration={brace,raise=5mm},decorate] (A) -- (O)
node [midway,yshift=-6mm,below] (R) {$6$};
\draw[decoration={brace,raise=5mm},decorate] (O) -- (P)
node [midway,yshift=-6mm,below] (r) {$x$};
\end{tikzpicture}
\end{document}
答案2
以下是一次快速尝试:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[fill=blue] (0,0)node[below]{$A$} arc (0:180:6) node[below]{$B$};
\draw (-12,0) - -(0,0);
\draw[fill=white] (-8,0) arc (0:180:2);
\draw[fill=white] (0,0) arc (0:180:4)node[below]{$P$};
\draw (-6,-0.1) -- node[below]{$O$} (-6,0.1);
\draw[<->](-8,-0.6)--node[below]{$x$}(-6,-0.6);
\draw[<->](-6,-0.6)--node[below]{$6$}(0,-0.6);
\end{tikzpicture}
\end{document}
得出的结果为:
请注意,着色/填充是累积的:您可以用一种颜色填充一个区域,然后用另一种颜色填充另一个重叠区域,或者white
删除该颜色。任何给定区域中的最后一个颜色获胜。
答案3
没有arc
s 但有circle
s 和clip
。
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[font=\footnotesize]
\begin{scope}
\clip (-3.1,-0.5\pgflinewidth) rectangle (3,3.1);
\filldraw[fill=blue] (0,0) circle (3cm);
\filldraw[fill=white] (1,0) circle (2cm);
\filldraw[fill=white] (-2,0) circle (1cm);
\end{scope}
\draw (-3,-0.5\pgflinewidth)
coordinate[label=-90:$B$] (B)
-- (-1,-0.5\pgflinewidth) coordinate[label=-90:$P$] (P)
--coordinate[pos=0.25,label=-90:$O$] (O)
(3,-0.5\pgflinewidth)coordinate[label=-90:$A$] (A) ;
\draw[|<->|,yshift=-5mm] ([yshift=-5mm]A) -- ([yshift=-5mm]O)
node [midway,below] (R) {$6$};
\draw[|<->|] ([yshift=-5mm]O) -- ([yshift=-5mm]P)
node [midway,below] (r) {$x$};
\end{tikzpicture}
\end{document}
答案4
我推荐使用 PSTricks 的解决方案。
\documentclass[pstricks,border=12pt,dvipsnames]{standalone}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}[showgrid=false](-5,-2)(5,5)
\pstGeonode[PosAngle=-90]
(0,0){O}
(5,0){A}
(-5,0){B}
(-2,0){P}
\begingroup
\psset{PointName=none,PointSymbol=none}
\pstMiddleAB{B}{P}{O'}
\pstMiddleAB{P}{A}{O''}
\endgroup
\pscustom[fillstyle=solid,fillcolor=NavyBlue]
{
\pstArcOAB{O}{A}{B}
\pstArcnOAB{O'}{B}{P}
\pstArcnOAB{O''}{P}{A}
\closepath
}
\pcline(B)(A)
\psset{arrows=|*-|*,shortput=nab}
\pcline[offset=-1](P)(O)_{$x$}
\pcline[offset=-1.5](O)(A)_{$r$}
\end{pspicture}
\end{document}