Tikz 库:命令 \draw ... to... with out and in 规范

Tikz 库:命令 \draw ... to... with out and in 规范

我想问一下以下命令如何工作:

\draw [] (0,0) to [out=20,in=120] (50,20) to [out=-60, in=110] (90,20);

我不知道.. .. 是什么部分to [out=20,in=120]。结果是一条曲线,但我不知道如何正确理解这些参数。

答案1

来自手册

如果您写入(a) to [out=135,in=45] (b)一条曲线,则该曲线将以 135° 的角度从 a 处出发,并以 45° 的角度到达 b 处。这是因为选项 in 和 out 会触发一条特殊路径,而不是直线。

这实际上允许您弯曲两点之间的路径。角度是相对于水平线指定的,或者,如果relative传递了选项,则相对于两点之间的直线指定。

考虑下面的简单例子: 例子

(a) to [out=20, in=120] (b)红色曲线是示例中的结果。outin参数指定的角度在图片上有描述。记住参数的一个简单方法是指定曲线的角度出去源节点,并输入目标节点。

要理解由选项“相对”引起的差异,请看以下两个示例:第一个示例不带选项relative,因此为绝对角度:

在此处输入图片描述

现在有了相对角度:

在此处输入图片描述

代码

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \node[circle,draw] (a) at (0,0) {a};
  \node[circle,draw] (b) at (10,0) {b};
  \draw[dashed] (a) -- (b);
  \draw[dashed] (a) -- +(20:10cm);
  \draw[dashed] (b) -- +(120:4cm);
  \draw[dashed] (b) -- +(0:3cm);

  \draw (a) +(4,0)  arc (0:20:4);
  \draw (a) + (10:4.3) node {$20^{\circ}$};
  \draw (b) + (2,0) arc (0:120:2);
  \draw (b) + (60:2.3) node {$120^{\circ}$};

  \draw[red] (a) to[out=20,in=120] (b);
\end{tikzpicture}

\clearpage

\begin{tikzpicture}
  \node[circle,draw] (a) at (0,0) {a};
  \node[circle,draw] (b) at (0,5) {b};
  \draw[dashed] (a) -- +(0:5cm);
  \draw[dashed] (a) -- +(20:10cm);
  \draw[dashed] (b) -- +(120:4cm);
  \draw[dashed] (b) -- +(0:3cm);

  \draw (a) +(4,0)  arc (0:20:4);
  \draw (a) + (10:4.3) node {$20^{\circ}$};
  \draw (b) + (2,0) arc (0:120:2);
  \draw (b) + (60:2.3) node {$120^{\circ}$};

  \draw[red] (a) to[out=20,in=120] (b);
\end{tikzpicture}

\clearpage

\begin{tikzpicture}[relative]
  \node[circle,draw] (a) at (0,0) {a};
  \node[circle,draw] (b) at (0,5) {b};
  \draw[dashed] (a) -- (b);
  \draw[dashed] (a) -- +(110:10cm);
  \draw[dashed] (b) -- +(210:4cm);
  \draw[dashed] (b) -- +(90:3cm);

  \draw (a) +(0,2)  arc (90:110:2);
  \draw (a) + (100:2.3) node {$20^{\circ}$};
  \draw (b) + (0,2) arc (90:210:2);
  \draw (b) + (120:2.3) node {$120^{\circ}$};

  \draw[red] (a) to[out=20,in=120] (b);
\end{tikzpicture}  


\end{document}

致谢

感谢 Paul Gaborit 对该选项的评论relative

相关内容