![垂直线和曲线之间的连接箭头](https://linux22.com/image/264134/%E5%9E%82%E7%9B%B4%E7%BA%BF%E5%92%8C%E6%9B%B2%E7%BA%BF%E4%B9%8B%E9%97%B4%E7%9A%84%E8%BF%9E%E6%8E%A5%E7%AE%AD%E5%A4%B4.png)
我想对下图做一些修改:
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{snakes,arrows}
\begin{document}
\begin{tikzpicture}
% draw the ground
\draw (0,0) -- (8.5,0) .. controls (8.5,-1) and (10,-1).. (11,-1) -- (14,-1);
% draw lake surface
\draw [snake = snake,segment amplitude =.4mm, segment length = 5mm] (8.5,0) -- (14,0);
% draw the wind velocity field
\draw[very thick,gray](12,0)--(12,5);
\draw (12,0)..controls(12.5,2) and(14,3) ..(14,5);% draw profile
\end{tikzpicture}
\end{document}
从此图中,我想从垂直直线到曲线添加水平箭头线。我的尝试:
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{snakes,arrows}
\begin{document}
\begin{tikzpicture}
% draw the ground
\draw (0,0) -- (8.5,0) .. controls (8.5,-1) and (10,-1).. (11,-1) -- (14,-1);
% draw lake surface
\draw [snake = snake,segment amplitude =.4mm, segment length = 5mm] (8.5,0) -- (14,0);
% draw the wind velocity field
\draw[very thick,gray](12,0)--(12,5);
\draw (12,0)..controls(12.5,2) and(14,3) ..(14,5);% draw profile
\foreach \y in {2,3,5}
\foreach \x in {12.5,14,14}{
\draw[=>stealth,->](12,\y)--(\x,\y);
}
\end{tikzpicture}
\end{document}
这显然是错误的,但我似乎无法解决这个问题。另外,我怎样才能让水平线在垂直方向上均匀分布 5 次?
答案1
该snakes
库已被弃用,请使用该decorations.pathmorphing
库代替。
为了找到曲线上的正确点,我使用了intersections
库。
曲线名为curve
。
\y
在从1
到 的循环中,从 到的5
路径被命名为(因此它与曲线路径相交)。和的交点被命名为,用于绘制路径。horizontal
(12, \y)
(15, \y)
curve
horizontal
intersection-1
代码
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,arrows,intersections}
\begin{document}
\begin{tikzpicture}
% draw the ground
\draw (0,0) -- (8.5,0) .. controls (8.5,-1) and (10,-1).. (11,-1) -- (14,-1);
% draw lake surface
\draw [decorate, decoration={snake,amplitude =.4mm, segment length = 5mm}] (8.5,0) -- (14,0);
% draw the wind velocity field
\draw[very thick,gray](12,0)--(12,5);
\draw[name path=curve] (12,0)..controls(12.5,2) and(14,3) ..(14,5);% draw profile
\foreach \y in {1,...,5}{
\path[name path=horizontal] (12,\y) -- + (3,0);
\draw[-stealth,name intersections={of=curve and horizontal}] (12,\y) -- (intersection-1);
}
\end{tikzpicture}
\end{document}