垂直线和曲线之间的连接箭头

垂直线和曲线之间的连接箭头

我想对下图做一些修改:

\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)curvehorizontalintersection-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}

输出

在此处输入图片描述

相关内容