TikZ 结点问题:使用双重时在交叉点处出现圆形“剪纸”

TikZ 结点问题:使用双重时在交叉点处出现圆形“剪纸”

我正在尝试使用 knots 包绘制带有连接圆的三位一体/三叶结,但在交叉点处遇到了“纸张圆形切口”问题,如下图所示。(模糊的圆形“麦田怪圈“伪影不是问题,仅在从 .pdf 转换为 .jpg 时可见。)

降低值可以double distance减轻问题,但不能消除问题。

使用环境外的圆弧手动绘制链接环knot是可行的,但众所周知的doublePDF 渲染伪影(在这里表现为两个连接点处的线double)问题破坏了整个事物的美感:大多数观众会以电子方式而不是在纸上看到事物。

这个问题有解决方法吗?我希望在调整以下代码中的参数后不需要大量的手动干预:我打算将数学和文本沿着链接的各个部分和结点内部流动,正确的参数需要动态调整。

三位一体剪纸

最小工作示例:

\documentclass[tikz]{standalone}% 

\usetikzlibrary{knots}

\begin{document}

\begin{tikzpicture}
    % Ring Parameters
    \pgfmathsetmacro{\RingRadius}{3};

    % Trefoil parameters
    \pgfmathsetmacro{\TrefoilAngle}{120};
    \pgfmathsetmacro{\InnRadius}{1};
    \pgfmathsetmacro{\OutRadius}{4};

    % Coordinates for trefoil bounding circle
    \coordinate (bottom) at (270:\OutRadius);
    \coordinate (left) at (150:\OutRadius);
    \coordinate (right) at (30:\OutRadius);

    % Coordinates for trefoil "hole"
    \coordinate (innBot) at (270:\InnRadius);
    \coordinate (innLeft) at (150:\InnRadius);
    \coordinate (innRight) at (30:\InnRadius);

    \begin{knot}[%
        % Use no splits to prevent: https://tex.stackexchange.com/q/708135
        consider self intersections = no splits,
        end tolerance=0.5pt,
        line width = 2,
        line join=round,
        clip width=1,
        ignore endpoint intersections=true,
        % draft mode = crossings,
        flip crossing/.list={2, 3, 8, 6},
        ]

        %%%%%%%%%%%%%
        %  Trefoil  %
        %%%%%%%%%%%%%
        \strand[%
            only when rendering/.style={%
            draw=teal,
            double=teal!20,
            double distance=9pt,
            },
        ]
        (innBot)
        to [out = 180, in = -30 - 0.5*\TrefoilAngle]
        (left)
        to [out = -30 + 0.5*\TrefoilAngle, in = 120]
        (innRight)
        to [out = -60, in = 90 - 0.5*\TrefoilAngle]
        (bottom)
        to [out = 90 + 0.5*\TrefoilAngle, in = -120]
        (innLeft)
        to [out = 60, in = -150 - 0.5*\TrefoilAngle]
        (right)
        to [in = 0, out = -150 + 0.5*\TrefoilAngle]
        (innBot)
        ;

        %%%%%%%%%%
        %  Ring  %
        %%%%%%%%%%
        \strand[
            only when rendering/.style={%
            draw=red,
            line width = 2pt,
            double=red!20,
            double distance=9pt,
            },
        ]
        (0, 0) circle [radius = \RingRadius];
    \end{knot}
\end{tikzpicture}

\end{document}

答案1

您需要设置clip radius一些合理的值。为了进行测试,您可以尝试:clip width=2, background color=yellow

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{knots}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\RingRadius}{3}
\pgfmathsetmacro{\TrefoilAngle}{120}
\pgfmathsetmacro{\InnRadius}{1}
\pgfmathsetmacro{\OutRadius}{4}
\coordinate (bottom) at (270:\OutRadius);
\coordinate (left) at (150:\OutRadius);
\coordinate (right) at (30:\OutRadius);
\coordinate (innBot) at (270:\InnRadius);
\coordinate (innLeft) at (150:\InnRadius);
\coordinate (innRight) at (30:\InnRadius);
\begin{knot}[
consider self intersections=no splits,
end tolerance=0.5pt,
flip crossing/.list={1,2,5,6,8},
clip width=1,
clip radius=20pt,
]
\strand[
teal, double=teal!20,
line width=2pt, double distance=9pt,
] (innBot)
to [out=180, in=-30 - 0.5*\TrefoilAngle] (left)
to [out=-30 + 0.5*\TrefoilAngle, in=120] (innRight)
to [out=-60, in=90 - 0.5*\TrefoilAngle] (bottom)
to [out=90 + 0.5*\TrefoilAngle, in=-120] (innLeft)
to [out=60, in=-150 - 0.5*\TrefoilAngle] (right)
to [in=0, out=-150 + 0.5*\TrefoilAngle] (innBot);
\strand[
red, double=red!20,
line width=2pt, double distance=9pt,
] (0,0) circle [radius=\RingRadius];
\end{knot}
\end{tikzpicture}
\end{document}

交错环三叶草

;之后请勿使用pgfmathsetmacro。您不需要only when rendering

相关内容