![使用 [out, in] 绘制曲线路径](https://linux22.com/image/387635/%E4%BD%BF%E7%94%A8%20%5Bout%2C%20in%5D%20%E7%BB%98%E5%88%B6%E6%9B%B2%E7%BA%BF%E8%B7%AF%E5%BE%84.png)
您能帮忙画一条连接 (0,3) 和 (0,4) 的曲线路径吗?即使读过相关内容,我仍然觉得带有 in 和 out 选项的 draw 命令很难。
\documentclass[border=5mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,patterns}
\begin{document}
\begin{tikzpicture}
\draw[decoration={aspect=.23, segment length=2.0285mm, amplitude=4.16mm,coil},decorate] (0,5.2) -- (0,4);
\draw(0,5.2)--(0,6)--(-1.4,6);
\draw(-1.5,6.5)--(-2,6)--(-3,6)--(-3,5);
\draw[fill=black](-3,5) circle(3pt);
\draw[fill=black](-3,4) circle(3pt);
\draw(-3,4)--(-3,3)--(0,3);
\draw (0,3) % Draws a line
to [out=-10,in=-40] (.24,3.1125)
to [out=10,in=70] (.641,3.6)
to [out=-90,in=30] (0,4);
\end{tikzpicture}
\end{document}
答案1
(0,3)
您可以尝试类似的方法在和之间绘制曲线(0,4)
。
\draw (0,3) to[out=30,in=210,looseness=2] (0,4);
另一种方法是使用controls
\draw (0,3) ..controls (1,3.25) and (-1,3.75).. (0,4);
结果:
完整代码:
\documentclass[border=5mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing,patterns}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\draw[decoration={aspect=.23, segment length=2.0285mm, amplitude=4.16mm,coil},decorate] (0,5.2) -- (0,4);
\draw(0,5.2)--(0,6)--(-1.4,6);
\draw(-1.5,6.5)--(-2,6)--(-3,6)--(-3,5);
\draw[fill=black](-3,5) circle(3pt);
\draw[fill=black](-3,4) circle(3pt);
\draw(-3,4)--(-3,3)--(0,3);
\draw (0,3) ..controls (1,3.25) and (-1,3.75).. (0,4);
\node[below] at (0,3) {With \texttt{controls}};
\end{scope}
\begin{scope}[xshift=5cm]
\draw[decoration={aspect=.23, segment length=2.0285mm, amplitude=4.16mm,coil},decorate] (0,5.2) -- (0,4);
\draw(0,5.2)--(0,6)--(-1.4,6);
\draw(-1.5,6.5)--(-2,6)--(-3,6)--(-3,5);
\draw[fill=black](-3,5) circle(3pt);
\draw[fill=black](-3,4) circle(3pt);
\draw(-3,4)--(-3,3)--(0,3);
\draw (0,3) to[out=30,in=210,looseness=2] (0,4);
\node[below] at (0,3) {With \texttt{to}};
\end{scope}
\end{tikzpicture}
\end{document}