如何绘制扭曲的曲线?

如何绘制扭曲的曲线?

我是 TikZ 的新手,所以如果我的问题太愚蠢,请原谅。

有人知道如何绘制像这样的过度交叉/下交叉的扭曲吗:

在此处输入图片描述

我知道如何修饰曲线,我的困难在于如何修饰交叉点和扭结。提前谢谢您!

答案1

您可以rubout使用这里

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[rubout/.style={/utils/exec=\tikzset{rubout/.cd,#1},
 decoration={show path construction,
      curveto code={
       \draw [white,line width=\pgfkeysvalueof{/tikz/rubout/line width}+2*\pgfkeysvalueof{/tikz/rubout/halo}] 
        (\tikzinputsegmentfirst) .. controls
        (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)  ..(\tikzinputsegmentlast); 
       \draw [line width=\pgfkeysvalueof{/tikz/rubout/line width},shorten <=-0.1pt,shorten >=-0.1pt] (\tikzinputsegmentfirst) .. controls
        (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast);  
      }}},rubout/.cd,line width/.initial=2pt,halo/.initial=0.5pt]
 \draw[rubout={line width=2pt,halo=1pt},decorate,looseness=2.5] 
   (0,0) to[out=90,in=90] (1,2) to[out=-90,in=-90] (0,4);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

您可以使用该knots包(包含在spath3)。

\draw和命令\path由 替换\strand,并且必须包含在knot环境中。

有一种draft模式可以让你突出显示交叉点。

截屏

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{knots}

\begin{document}


Two examples from the knots package manual (p 9):


\begin{tikzpicture}


\begin{knot}[consider self intersections,draft mode=crossings]
\strand (0,0) .. controls +(3,1) and +(-3,1) .. (1,0);
\end{knot}

\begin{knot}[xshift=3cm,consider self intersections=no splits,draft mode=crossings]
\strand (0,0) .. controls +(3,1) and +(-3,1) .. (1,0);
\end{knot}

\end{tikzpicture}

The final result is:

\begin{tikzpicture}
\begin{knot}[xshift=6cm,consider self intersections,draft mode=off]
\strand (0,0) .. controls +(3,1) and +(-3,1) .. (1,0);
\end{knot}
\end{tikzpicture}

A figure similar to yours is:

\begin{tikzpicture}[]
\begin{knot}[consider self intersections=no splits,draft mode=off]
\strand (0,-1) .. controls (0,-4) and (2,-4) .. (2,-3)..controls (2,-2) and (0,-2)..(0,-5);
\end{knot}
\end{tikzpicture}
\end{document} 

相关内容