我正在尝试绘制一个区域。我无法绘制与连接内部区域和外部区域的线平行的箭头。这是我所拥有的
我目前拥有的代码如下。提前致谢。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{graphicx,wrapfig}
\usetikzlibrary{calc,hobby} % To draw the smooth curve
\begin{document}
\begin{tikzpicture}
\draw (0,1) to [closed,curve through={(2,3) (3.3,4) (3,6) (-1,6)(-1.4,5)(-3,3.8) }] (0,1);
\draw [blue](1,5) to [closed,curve through={(1.3,5.6)(2,5.8)(2.4,5.2)(2.2,4.7) (1.4,4.6)}] (1,5);
\draw [red](-1.6,2.5) to [closed,curve through={(-1.5,2.7)(-0.5,3.3)(-0.1,2.7)(-0.3,2.2) (-0.9,1.9)}] (-1.6,2.5);
\draw[densely dashed] (101:2.15) -- (74:1.3);
\draw[->] (101:1.75) -- (77:1);
\end{tikzpicture}
\end{document}
答案1
由于您已在加载calc
,因此可以使用部分的方法13.5.4 距离修饰符的语法pgfmanual v3.1.5(以及部分13.5.3 部分修饰语的句法) 来定义距离虚线路径有一定距离的点。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc,hobby} % To draw the smooth curve
\begin{document}
\begin{tikzpicture}
\draw (0,1) to [closed,curve through={(2,3) (3.3,4) (3,6) (-1,6)(-1.4,5)(-3,3.8) }] (0,1);
\draw [blue](1,5) to [closed,curve through={(1.3,5.6)(2,5.8)(2.4,5.2)(2.2,4.7) (1.4,4.6)}] (1,5);
\draw [red](-1.6,2.5) to [closed,curve through={(-1.5,2.7)(-0.5,3.3)(-0.1,2.7)(-0.3,2.2) (-0.9,1.9)}] (-1.6,2.5);
\draw[densely dashed] (101:2.15) -- (74:1.3) coordinate [pos=0] (p0)
coordinate [pos=1] (p1);
\draw[-stealth] ($ ($(p0)!0.2!(p1)$)!0.3cm!90:(p1) $) --
($ ($(p0)!0.8!(p1)$)!0.3cm!90:(p1) $) ;
\end{tikzpicture}
\end{document}
但是,由于您似乎想要构建与这些曲线正交的线段,因此我建议采用另一种方法。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta,bending,hobby,intersections,decorations.markings} % To draw the smooth curve
\tikzset{%
attach arrow/.style={
decoration={
markings,
mark=at position 0 with {\pgfextra{%
\pgfmathsetmacro{\tmpArrowTime}{\pgfkeysvalueof{/tikz/arc arrow/length}/(\pgfdecoratedpathlength)}%
\xdef\tmpArrowTime{\tmpArrowTime}}},
mark=at position {#1-3*\tmpArrowTime} with {\coordinate(@1);},
mark=at position {#1-2*\tmpArrowTime} with {\coordinate(@2);},
mark=at position {#1-1*\tmpArrowTime} with {\coordinate(@3);},
mark=at position {#1+\tmpArrowTime/2} with {\coordinate(@4);
\draw[-{Stealth[length=\pgfkeysvalueof{/tikz/arc arrow/length},bend]}] plot[smooth]
coordinates {(@1) (@2) (@3) (@4)};},
},
postaction=decorate,
},
attach arrow/.default=0.5,
arc arrow/.cd,length/.initial=2mm,
}
\begin{document}
\begin{tikzpicture}
\draw[name path=outer,attach arrow/.list={0.1,0.6,0.9}] (0,1) to [closed,curve through={(2,3) (3.3,4) (3,6) (-1,6)(-1.4,5)(-3,3.8) }] (0,1);
\def\BluePath{(1,5) to [closed,curve through={(1.3,5.6)(2,5.8)(2.4,5.2)(2.2,4.7) (1.4,4.6)}] (1,5)}
\draw[blue,attach arrow/.list={0.2,0.7}] \BluePath;
\path[postaction={decorate,decoration={markings,
mark=at position 0.4 with {\path[overlay,name path=blue] (0,0) coordinate (b0) -- (0,2) coordinate (b1);}}}]
\BluePath;
\def\RedPath{(-1.6,2.5) to [closed,curve through={(-1.5,2.7)(-0.1,2.7)(-0.3,2.2) (-0.9,1.9)}] (-1.6,2.5)}
\draw[red,attach arrow/.list={0.3,0.8}] \RedPath;
\path[postaction={decorate,decoration={markings,
mark=at position 0.65 with {\path[overlay,name path=red] (0,0) coordinate (r0) -- (0,2) coordinate (r1);}}}]
\RedPath;
\draw[densely dashed,
name intersections={of=blue and outer,by=b1},
postaction={decorate,decoration={markings,
mark={at position 0.5 with {
\draw[-stealth,solid] (-0.2,0.2) -- (0.2,0.2);
\draw[-stealth,solid] (0.2,-0.2) -- (-0.2,-0.2);}}}}]
(b0) -- (b1);
\draw[densely dashed,
name intersections={of=red and outer,by=r1},
postaction={decorate,decoration={markings,
mark={at position 0.5 with {
\draw[-stealth,solid] (-0.2,0.2) -- (0.2,0.2);
\draw[-stealth,solid] (0.2,-0.2) -- (-0.2,-0.2);}}}}]
(r0) -- (r1);
\end{tikzpicture}
\end{document}