Tikzpicture 路径曲率问题

Tikzpicture 路径曲率问题

我写了以下代码:

\begin{tikzpicture}
\draw[->] (-1,0) to node [auto]{$f$} (1,0);

\draw (-5,-1) node(0)[label=below:{$v_0$}, circle,fill=black,scale=0.3]{};
\draw (-2,-1) node(1)[label=below:{$v_1$}, circle,fill=black,scale=0.3]{};
\draw (-3.5,1) node(2)[label=above:{$v_2$}, circle,fill=black,scale=0.3]{};

\path (0) edge node {} (1);
\path (1) edge node {} (2);

\draw [gray!50, step=0.5cm] (1.9999,-2) grid (8,2);

\draw (2,-1) -- (8,-1);
\draw (3,-2) -- (3,2);

\draw (3,-1) node(f0)[label=below:{$f(v_0)$}, circle,fill=black,scale=0.3]{};
\draw (7.5,-1) node(f1)[label=below:{$f(v_1)$}, circle,fill=black,scale=0.3]{};
\draw (4.5,1.5) node(f2)[label=above:{$f(v_2)$}, circle,fill=black,scale=0.3]{};

\path[very thick] (f0) edge node {} (f1);
\draw[very thick] (f2) to [bend angle = 36, bend left] (f1);

\draw[very thick, dashed] (4.5,1.5) to (3,-1);
\foreach \x in {1,...,17}
\draw[thick, dashed] (4.5,1.5) to [bend angle = \x*2, bend left] (3+0.25*\x,-1);
\end{tikzpicture}

绘制出来如下:

绘制代码的图像

然而我的问题是,当 $\x \to 17$ 时,绘制的虚线路径的曲率应该接近实心黑线的曲率,但正如你在图片中看到的那样,显然它不是。

有谁知道我该如何解决这个问题?

谢谢!

答案1

这招有用吗?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{intersections}
\begin{document}

\begin{tikzpicture}[aeang/.style={red,#1}]
\draw[->] (-1,0) to node [auto]{$f$} (1,0);

\draw (-5,-1)  node(0)[label=below:{$v_0$}, circle,fill=black,scale=0.3]{};
\draw (-2,-1)  node(1)[label=below:{$v_1$}, circle,fill=black,scale=0.3]{};
\draw (-3.5,1) node(2)[label=above:{$v_2$}, circle,fill=black,scale=0.3]{};

\path (0) edge node {} (1);
\path (1) edge node {} (2);

\draw [gray!50, step=0.5cm] (1.9999,-2) grid (8,2);

\draw (2,-1) -- (8,-1);
\draw (3,-2) -- (3,2);

\draw (3,-1)    node(f0)[label=below:{$f(v_0)$}, circle,fill=black,scale=0.3]{};
\draw (7.5,-1)  node(f1)[label=below:{$f(v_1)$}, circle,fill=black,scale=0.3]{};
\draw (4.5,1.5) node(f2)[label=above:{$f(v_2)$}, circle,fill=black,scale=0.3]{};

\path[very thick] (f0) edge node {} (f1);
\draw[very thick] (f2) to [bend angle = 36, bend left] (f1);

\draw[very thick, dashed] (f2) to (f0);
\foreach \x in {2.5,5,...,100}
{
  \pgfmathparse{36*\x/100}\edef\aeangle{\pgfmathresult}
  \pgfmathparse{1-\x/100} \edef\aedestination{\pgfmathresult}
  \draw[thin,red, dashed]
      let \p0=(f0),
          \p1=(f1) in
     (f2) to [bend angle = \aeangle, bend left] ($(f1)-({(\x1-\x0)*\aedestination},0)$);
}

\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

找到了。试试这个:

\begin{tikzpicture}
\foreach \x in {1,...,18}
\draw[thick] (4.5,1.5) to [bend angle = 2*\x, bend left] (3+0.5*\x,-1)
    node [below]{\tiny\x};

\draw[thick, red]  (4.5,1.5) to [bend angle = 36, bend left](3+0.5*18, -1) 
    node [below right]{\tiny E};
\end{tikzpicture}

你有:

在此处输入图片描述

但是将红线改为:

\draw[thick, red]  (4.5,1.5) to [bend angle = 2*18, bend left](3+0.5*18, -1) 
     node [below right]{\tiny E};

你有:

在此处输入图片描述

因此问题在于bend angle参数中的乘法未执行 --- 该命令不具备数学意识。一些实验导致了这种情况:

\begin{tikzpicture}
\draw[thick, blue]  (4.5,1.5) to [bend angle = 18, bend left](3+0.5*18, -1);
\draw[thick, red]  (4.5,1.5) to [bend angle = 18*2, bend left](3+0.5*18, -1);
\draw[thick, green]  (4.5,1.5) to [bend angle = 36, bend left](3+0.5*18, -1);
\end{tikzpicture}

其呈现为(我不知道为什么,我认为至少其中两个会一致):

在此处输入图片描述

您的代码的最小解决方案是用foreach以下内容替换:

\foreach \x in {2,4,...,34}
\draw[thick, dashed] (4.5,1.5) to [bend angle = \x, bend left] (3+0.125*\x,-1);

这将给你这个:

在此处输入图片描述

答案3

您可以对弯曲角度进行稍微更好的控制,使同伦度在 0 到 36 度之间。然后您可以将其用作按键in,out。代码中唯一的变化是

\foreach \x[evaluate={\xc={(36/17)*(\x-1)};}] in {1,...,17}{
  \draw[thick, dashed] (4.5,1.5) to [out=\xc,in=180-\xc,relative] (3+0.25*\x,-1);
}

请注意,这与书写相同[bend angle=\xc,bend left]。只需放在那里,就可以看见弯曲的作用。

在此处输入图片描述

相关内容