我需要将一条边分成多个相等的部分。对于直边,我有以下方法可以做到这一点:
\begin{tikzpicture}
[very thick, transform shape, scale=.2,
rect/.style={rectangle, }
]
\node[rect, fill = red,minimum width =.005cm, minimum height = 1cm] (1) at (20,0) {};
\node[rect, fill = red,minimum width =.005cm, minimum height = 1cm] (2) at (0,0) {};
\node[rect, fill = red, minimum width =.005cm, minimum height = 1cm ](3) at (5,0) {};
\node[rect, fill = red, minimum width =.005cm, minimum height = 1cm ](4) at (10,0) {};
\node[rect, fill = red, minimum width =.005cm, minimum height = 1cm ](5) at (15,0) {};
\path[-]
(1) edge[bend left = 0, red] node {} (2)
;
\end{tikzpicture}
结果是:
我想对弯曲的边缘做类似的事情。我的问题是我想不出一个简单的方法来找到弯曲边缘的相等线段的坐标,然后旋转每个节点使其垂直于边缘。
我希望找到一种方法,不需要定义边缘分隔线的坐标或分隔线的旋转,这可能吗?
如果没有人知道我可以在哪里找到有关 tikz 中使用的贝塞尔曲线的信息,因为我可以尝试编写一个程序来计算这些点处的曲线的位置和斜率。
这是我通常定义弯曲边缘的方式:
\begin{tikzpicture}
[very thick, transform shape, scale=.2,
rect/.style={rectangle, }
]
\node[rect, rotate=90,fill = red,minimum width =.005cm, minimum height = 1cm] (1) at (20,0) {};
\node[rect, rotate=90, fill = red,minimum width =.005cm, minimum height = 1cm] (2) at (0,0) {};
\node[rect, fill = red, minimum width =.005cm, minimum height = 1cm ](3) at (5,0) {};
\node[rect, fill = red, minimum width =.005cm, minimum height = 1cm ](4) at (10,0) {};
\node[rect, fill = red, minimum width =.005cm, minimum height = 1cm ](5) at (15,0) {};
\path[-]
(1) edge[bend left = -90, red] node {} (2)
;
\end{tikzpicture}
这使:
答案1
您可以使用decoration
。主要问题是路径末尾的标记(请参阅Tikz:路径末端的装饰在高弯曲角度下消失)。
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{positioning, decorations.markings}
\begin{document}
\begin{tikzpicture}
[very thick,
decoration={markings,
mark=between positions 0 and 1 step .25 with {\node[inner xsep=1pt, fill=black, transform shape]{};}}
]
\draw[postaction={decorate}] (0,0) to[out=90, in=90] (4,0) node[inner xsep=1pt, fill=black, rotate=90]{};
\end{tikzpicture}
\end{document}
答案2
与@Ignasi 的回答非常相似,主要区别在于我使用条形箭头来绘制条形。这样可以避免手动旋转消失的标记。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
\draw[red,very thick,-Bar,postaction={decorate},
decoration={markings,
mark=between positions 0 and 1 step .25 with {
\arrow{Bar};}}] (0,0) to[out=90, in=90] (4,0);
\end{tikzpicture}
\end{document}