答案1
您可以利用\pic
s 然后轻松放置和连接它们。
扩展 MS-SPO 的精彩答案:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\tikzset{
pics/incomplete semicircle/.style={
code={
\tikzset{
incomplete semicircle/.cd,
#1,
arrow decoration outer/.style={
decoration={
markings,
mark={at position 0.08 with {\arrow{stealth}}},
mark={at position 0.20 with {\arrow{stealth}}},
mark={at position 0.32 with {\arrow{stealth}}},
mark={at position 0.44 with {\arrow{stealth}}},
mark={at position 0.57 with {\arrow{stealth}}},
mark={at position 0.76 with {\arrow{stealth}}},
mark={at position 0.95 with {\arrow{stealth}}}
},
postaction={decorate}
},
arrow decoration inner/.style={
decoration={
markings,
mark={at position 0.3 with {\arrow{stealth}}},
mark={at position 0.8 with {\arrow{stealth}}}
},
postaction={decorate}
}
}
\coordinate (-A) at (150:1);
\coordinate (-B) at (120:1);
\coordinate (-C) at (90:1);
\coordinate (-D) at (60:1);
\coordinate (-E) at (30:1);
\coordinate (-F) at (0:.5);
\coordinate (-G) at (90:.5);
\coordinate (-H) at (0:-.5);
\draw[incomplete semicircle/arrow decoration outer]
(-A) arc[start angle=150, end angle=30, radius=1] --
(-F) -- (-H) -- cycle;
\draw[incomplete semicircle/arrow decoration inner]
(-H) -- (-G) -- (-F);
\foreach \p in {A,B,...,H}{
\node[circle, draw, fill=white, inner sep=0.75pt]
(-n\p) at (-\p) {};
}
}
},
arrowed/.style={
decoration={
markings,
mark={at position 0.55 with {\arrow{stealth}}}
},
postaction={decorate}
}
}
\begin{document}
\begin{tikzpicture}
\pic (c1) at (0,0) {incomplete semicircle};
\pic (c2) at (2,0) {incomplete semicircle};
\draw[arrowed] (c1-nF) -- (c2-nH);
\draw[arrowed] (c2-nA) -- (c1-nF);
\end{tikzpicture}
\end{document}
答案2
以下是一些开始的内容。主要步骤:
- 忽略
postaction
,绘制“半圆”和实心圆很容易 - 使用起来
polar coorinates
很容易,记住 3 个coordinate
A、B 和 C arc
移动到起始位置后需要 3 个参数: (startAngle:endAngle:radius )decorations.markings
最后使用lib添加装饰- 对定位进行一些微调
当然,一些代码部分可以进一步重构为一些foreach
循环。
不幸的是,我没能成功将整个绘图移到 中\pic
。一旦成功,就很容易了:
- 把其中 5 个排成一行
- 从内部访问坐标
\pic
或明确指定它们 - 绘制缺失的几个连接器
\documentclass[10pt,border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
[decoration={
markings,
mark=between positions 0.06 and 1 step 5.3mm with {\arrow{stealth}}
}]
% ~~~ "semicircle" ~~~~~~~~~~
\draw [postaction={decorate}] (150:1) arc(150:30:1) -- (0:.5) coordinate (B) -- (0:-.5) coordinate (A) -- (150:1) (A) -- (90:.5) coordinate (C) -- (B) ;
% ~~~ filled circles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\draw [fill=white] (150:1) circle [radius=1pt];
\draw [fill=white] (120:1) circle [radius=1pt];
\draw [fill=white] (90:1) circle [radius=1pt];
\draw [fill=white] (60:1) circle [radius=1pt];
\draw [fill=white] (30:1) circle [radius=1pt];
\draw [fill=white] (A) circle [radius=1pt];
\draw [fill=white] (B) circle [radius=1pt];
\draw [fill=white] (C) circle [radius=1pt];
\end{tikzpicture}
\end{document}
最后,这里是重构实心圆位置的代码:
\documentclass[10pt,border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
[decoration={
markings,
mark=between positions 0.06 and 1 step 5.3mm with {\arrow{stealth}}
}]
% ~~~ "semicircle" ~~~~~~~~~~
\draw [postaction={decorate}] (150:1) arc(150:30:1) -- (0:.5) coordinate (B) -- (0:-.5) coordinate (A) -- (150:1) (A) -- (90:.5) coordinate (C) -- (B) ;
% ~~~ filled circles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% refactored
\foreach \p in {(150:1),(120:1),(90:1),(60:1),(30:1),(A),(B),(C)}{
\draw [fill=white] \p circle [radius=1pt];
}
\end{tikzpicture}
\end{document}
正如贾斯珀(Jasper)评论的那样,半圆的路径至少应该在这里分开:
... coordinate (A) -- (150:1) (A) -- (90:.5) coordinate (C) ...
我继续画最后 3 个点,纯粹是为了偷懒。定义第二种装饰风格,以便更好地放置箭头,这也是一种选择。提前一个点开始“半圆”也可能是一个不错的选择,即在弧线之前,即在左下角。可能会产生一些有益的结果。
事实证明,你也可以分割装饰风格;左下角的点很关键,因为有两条路径穿过它:
\documentclass[10pt,border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
[decoration={
markings,
mark=between positions 0.06 and .5 step 5.3mm with {\arrow{stealth}} ,
mark=between positions 0.6 and .8 step 6mm with {\arrow{stealth}} ,% new
mark=between positions 0.835 and 1 step 6mm with {\arrow{stealth}}% new
}]
% ~~~ "semicircle" ~~~~~~~~~~
\draw [postaction={decorate}] (150:1) arc(150:30:1) -- (0:.5) coordinate (B) -- (0:-.5) coordinate (A) -- (150:1) (A) -- (90:.5) coordinate (C) -- (B) ;
% ~~~ filled circles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% refactored
\foreach \p in {(150:1),(120:1),(90:1),(60:1),(30:1),(A),(B),(C)}{
\draw [fill=white] \p circle [radius=1pt];
}
\end{tikzpicture}
\end{document}