增加 tikz 中圆的边界部分的厚度

增加 tikz 中圆的边界部分的厚度

我在 tikz 中绘制了一个圆,对于圆边界上的两个特定坐标,我希望增加圆边界的粗细。我该怎么做?

最小工作示例:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\draw[-] (2,0) circle (1.5);
%draw darkened arc from (0.58,-0.5) to (3.45,0.3)
\end{tikzpicture}
\end{figure}
\end{document}

答案1

如果你知道角度的话最简单:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[-] (2,0) circle (1.5);
%draw darkened arc from (0.58,-0.5) to (3.45,0.3)
\draw [very thick] (2,0) ++(210:1.5) arc[start angle=210,delta angle=-150,radius=1.5];
\end{tikzpicture}
\end{document}

尽管它们可以计算出来:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (o) at (2,0);
\draw[-] (o) circle (1.5);
\coordinate (s1) at (0.58,-0.5);
\coordinate (s2) at (3.45,0.3);
\draw [very thick] 
let
\p1=(o), \p2=(s1),\p3=(s2),\n1={atan2(\y2-\y1,\x2-\x1)},\n2={atan2(\y3-\y1,\x3-\x1)}
in
(o) ++(\n1:1.5) arc[start angle=\n1,end angle=\n2,radius=1.5];

\draw [very thick,red] 
let
\p1=(o), \p2=(s1),\p3=(s2),
\n1={ifthenelse(atan2(\y2-\y1,\x2-\x1)<0,atan2(\y2-\y1,\x2-\x1)+360,atan2(\y2-\y1,\x2-\x1))},
\n2={ifthenelse(atan2(\y3-\y1,\x3-\x1)<0,atan2(\y3-\y1,\x3-\x1)+360,atan2(\y3-\y1,\x3-\x1))}
in
(o) ++(\n1:1.5) arc[start angle=\n1,delta angle=\n2-\n1,radius=1.5];

\end{tikzpicture}
\end{document}

在此处输入图片描述

因此,这似乎并非在所有情况下都能完美地工作。但是,当使用第二个选项时,您只需从中减去 360 即可以delta angle另一种方式绘制圆弧,即delta angle=\n2-\n1-360

\documentclass[border=4mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\coordinate (o) at (2,0);
\draw[-] (o) circle (1.5);
\coordinate (s1) at (2,-1.5);
\coordinate (s2) at (3.4,-0.5);
\draw [very thick] 
let
\p1=(o), \p2=(s1),\p3=(s2),\n1={atan2(\y2-\y1,\x2-\x1)},\n2={atan2(\y3-\y1,\x3-\x1)}
in
(o) ++(\n1:1.5) arc[start angle=\n1,end angle=\n2,radius=1.5];

\draw [very thick,red] 
let
\p1=(o), \p2=(s1),\p3=(s2),
\n1={ifthenelse(atan2(\y2-\y1,\x2-\x1)<0,atan2(\y2-\y1,\x2-\x1)+360,atan2(\y2-\y1,\x2-\x1))},
\n2={ifthenelse(atan2(\y3-\y1,\x3-\x1)<0,atan2(\y3-\y1,\x3-\x1)+360,atan2(\y3-\y1,\x3-\x1))}
in
(o) ++(\n1:1.5) arc[start angle=\n1,delta angle=\n2-\n1-360,radius=1.5];

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

剪辑是另一个简单的选择。

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\coordinate (a) at (0.58,-.5);
\coordinate (b) at (3.45,0.3);
\draw[-] (2,0) circle (1.5);
\draw (a) circle (0.1);
\draw (b) circle (0.1);
\begin{scope}
    \clip (a) -- (b) -- ++(80:1.5) -- ++(180:4) -- cycle;
    \draw[very thick,red] (2,0) circle (1.5);
\end{scope}
%draw darkened arc from (0.58,-0.5) to (3.45,0.3)
\end{tikzpicture}
\end{figure}
\end{document}

在此处输入图片描述

相关内容