如何在 tikz 中绘制线条的移动?

如何在 tikz 中绘制线条的移动?

如何绘制图1中的第一幅图报纸在第 2 页?

我想画一个类似的六边形。以下是我的代码。

\begin{tikzpicture}
\foreach \a in {1,2,...,5} { %\a is the angle variable
\draw (-\a*72+72*2+18:2cm)--(-\a*72+72*3+18:2cm); 
}

\coordinate (b1) at (-1*72+72*2+18:2cm);
\coordinate (b2) at (-2*72+72*2+18:2cm);
\coordinate (b3) at (-3*72+72*2+18:2cm);
\coordinate (b4) at (-4*72+72*2+18:2cm);
\coordinate (b5) at (-5*72+72*2+18:2cm);

\draw (-1*72+72*2+18:2cm)--(-5*72+72*3+18:2cm); 

\node(a1) at (-1*72+72*2+18:2cm) [above=1] {1};
\node(a2) at (-2*72+72*2+18:2cm) [right=1] {2};
\node(a3) at (-3*72+72*2+18:2cm) [right=1] {3};
\node(a4) at (-4*72+72*2+18:2cm) [left=1] {4};
\node(a5) at (-5*72+72*2+18:2cm) [left=1] {5};

\end{tikzpicture}

我想画一个与 2 到 1 的线平行的红色箭头,并与 1 到 4 的线相交。当与 1 到 4 的线相交时,此箭头结束。如何在 tikz 中执行此操作?我尝试移动 1 和 2 的坐标,但没有成功。

非常感谢。

我想要绘制的图表是在此处输入图片描述

答案1

这是一个建议。

\documentclass[tikz,border=3.14pt]{standalone}
\usetikzlibrary{calc,intersections}
% from https://tex.stackexchange.com/a/39282/121799
\usetikzlibrary{decorations.markings}
\tikzset{->-/.style={postaction={decorate,decoration={
  markings,
  mark=at position #1 with {\arrow{>};}}}}}
\begin{document}
\begin{tikzpicture}
\foreach \a in {1,2,...,5} { %\a is the angle variable
\draw (-\a*72+72*2+18:2cm) coordinate[label=-\a*72+72*2+18:\a] (b\a) --(-\a*72+72*3+18:2cm); 
}
\draw[name path=bl14] (-1*72+72*2+18:2cm)--(-5*72+72*3+18:2cm); 

\def\mydist{2.5mm}

\draw[red,-latex] ($ (b4)!\mydist!90:(b1) $) -- ($ (b1)!\mydist!-90:(b4) $);

\path[name path=aux21] ($ (b2)!\mydist!90:(b1) $) -- ($ (b1)!\mydist!-90:(b2) $);
\path[name path=aux54] ($ (b5)!\mydist!90:(b4) $) -- ($ (b4)!\mydist!-90:(b5) $);
\path[name path=aux43] ($ (b4)!\mydist!90:(b3) $) -- ($ (b3)!\mydist!-90:(b4) $);

\draw[red,-latex,shorten <=-3mm,name intersections={of=aux21 and bl14,by=aux1}]
($ (b2)!\mydist!90:(b1) $) -- (aux1);
\draw[red,-latex,shorten >=-3mm] (aux1) -- ($ (b5)!\mydist!-90:(b1) $);

\draw[red,-latex,shorten <=-3mm,name intersections={of=aux54 and bl14,by=aux2}]
($ (b5)!\mydist!90:(b4) $) -- (aux2);

\draw[red,-latex,shorten >=-3mm,name intersections={of=aux43 and bl14,by=aux3}]
 (aux3) -- ($ (b3)!\mydist!-90:(b4) $);

\draw[red,-latex,shorten >=-3mm,shorten <=-3mm] ($ (b3)!\mydist!90:(b2) $) -- ($ (b2)!\mydist!-90:(b3) $);

\begin{scope}[xshift=6cm,>=latex]
 \draw (0,0) circle (2);
 \foreach \X [evaluate=\X as \Y using 90+72-72*\X] in {1,...,5}
 {\node[fill,circle,inner sep=1.5pt,label=\Y:\X] (c\X) at (\Y:2){};}
 \draw[->-/.list={1/6,1/2,5/6}] (c4) to[bend left=15] (c1);
 \draw[->-/.list={1/6,1/2,5/6}] (c1) to[bend left=15] (c4);
 \draw[->-/.list={1/6,1/2,5/6}] (c5) to[bend right=15] (c3);
 \draw[->-/.list={1/2}] (c3) to[bend right=15] (c2);
 \draw[->-/.list={1/6,1/2,5/6}] (c2) to[bend right=15] (c5);
\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容