TikZ Knots パッケージ: スケーリング後に交差が変更されました

TikZ Knots パッケージ: スケーリング後に交差が変更されました

結び目図のスケールを変えると、交差の1つが変わることに気づきました。交差は正しいはずです。2番以下のコードによって生成された図。どうしてこうなったのかわかりません。使用してみましたdraft mode=crossingsが、役に立ちませんでした。最初の図の交差を正しいバージョンに切り替えるのに助けていただけないでしょうか?

これが私のコードです:

\documentclass[a4paper,11pt]{report}
\usepackage{graphicx,amssymb,amstext,amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc}

\begin{document}

\tikzset{
  knot diagram/every strand/.append style={
    line width=1.5pt,violet
  },
}

\tikzset{
  my style/.style={
    dashed
  }
}

\begin{tikzpicture}[scale=0.9, use Hobby shortcut, add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.25 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.653 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.75 with {\arrow[line width=1.5pt]{<}}}}]
\begin{knot}[
  consider self intersections=true,
  ignore endpoint intersections=false,
  flip crossing=3,
  rotate=180]
  \strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
  \strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9); 
  \strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
\end{knot}
\path (0,-.7);
\end{tikzpicture}

%---------------------------------------------------------------

\begin{tikzpicture}[scale=2, use Hobby shortcut, add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.25 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.653 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.75 with {\arrow[line width=1.5pt]{<}}}}]
\begin{knot}[
  consider self intersections=true,
  ignore endpoint intersections=false,
  flip crossing=3,
  rotate=180]
  \strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
  \strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9); 
  \strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
\end{knot}
\path (0,-.7);
\end{tikzpicture}

\end{document}

答え1

ここでの根本的な問題は、交差点が別の (太い) 線に近い場合の「knots」tikz ライブラリの予期しない動作: 何が起こっているのでしょうか?非常に接近した交差点が 2 つあり、クリッピング サークル (交差点が描画されるとき) が重なり合っています。つまり、紫色の線が灰色の破線の上に描画されると、問題のある交差点でも紫色の線が重なって描画されます。

考えられる修正方法をいくつか示します。最初の方法では、クリッピング サークルの半径を小さくします。2 番目の方法では、実際には結び目の一部ではないと思われる灰色の破線を結び目から削除します (結び目に残しておきたい場合は、only when renderingその部分のキーを使用する必要がありますdashed。詳細についてはドキュメントを参照してください)。3 番目の方法では、趣味のパスを少し簡略化します。

結果:

さまざまな修正

コード:

\documentclass[a4paper,11pt]{report}
%\url{https://tex.stackexchange.com/q/478294/86}
\usepackage{shellesc}
\usepackage{graphicx,amssymb,amstext,amsmath}
\usepackage{tikz}
\usetikzlibrary{
  decorations.pathreplacing,
  decorations.markings,
  hobby,
  knots,
  celtic,
  shapes.geometric,
  calc,
  external
}

\tikzexternalize

\begin{document}

\tikzset{
  knot diagram/every strand/.append style={
    line width=1.5pt,violet
  },
}

\tikzset{
  my style/.style={
    dashed
  }
}




Demonstration of the problem: the clipping circles are big enough that the circle associated with the crossing between the violet line and the dashed grey line overlaps the problematic crossing.

\tikzsetnextfilename{problem}
\begin{tikzpicture}[scale=0.9, use Hobby shortcut, add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.25 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.653 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.75 with {\arrow[line width=1.5pt]{<}}}}]
\begin{knot}[
  consider self intersections=true,
  ignore endpoint intersections=false,
  flip crossing=3,
  background clip/.append style={
    preaction={
      fill=gray,
      fill opacity=.5,
    }
  },
  rotate=180]
  \strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
  \strand[knot diagram/only when rendering/.style={my style}, lightgray] (-0.7,-1.2) -- (-0.7,-.9); 
  \strand[knot diagram/only when rendering/.style={my style}, lightgray] (-0.7,-.75) -- (-0.7,2.5);
\end{knot}
\path (0,-.7);
\end{tikzpicture}

%---------------------------------------------------------------

Fix one: shrink the clipping circles using the \verb+clip radius+ key.

\tikzsetnextfilename{fix-one}
\begin{tikzpicture}[scale=0.9, use Hobby shortcut, add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.25 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.653 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.75 with {\arrow[line width=1.5pt]{<}}}}]
\begin{knot}[
  consider self intersections=true,
  ignore endpoint intersections=false,
  flip crossing=3,
  clip radius=3pt,
  background clip/.append style={
    preaction={
      fill=gray,
      fill opacity=.5,
    }
  },
  rotate=180]
  \strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
  \strand[knot diagram/only when rendering/.style={my style}, lightgray] (-0.7,-1.2) -- (-0.7,-.9); 
  \strand[knot diagram/only when rendering/.style={my style}, lightgray] (-0.7,-.75) -- (-0.7,2.5);
\end{knot}
\path (0,-.7);
\end{tikzpicture}

Fix two: the dashed grey lines don't appear to actually be anything to do with the knot, so draw them separately.
This means that there aren't two crossings near to each other any more.

\tikzsetnextfilename{fix-two}
\begin{tikzpicture}[scale=0.9, use Hobby shortcut, add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.25 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.653 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.75 with {\arrow[line width=1.5pt]{<}}}}]
\draw[
  line width=1.5pt,
  my style,
  lightgray,
  rotate=180
] (-0.7,-1.2) -- (-0.7,2.5);
\begin{knot}[
  consider self intersections=true,
  ignore endpoint intersections=false,
%  flip crossing=6,
  rotate=180]
  \strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
\end{knot}
\path (0,-.7);
\end{tikzpicture}

Fix three: you specify a lot of \emph{nodes} in your Hobby path.
If you aren't wedded to that specific path then reducing the number of nodes can simplify the knot algorithm.

\tikzsetnextfilename{fix-three}
\begin{tikzpicture}[scale=0.9, use Hobby shortcut, add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.2 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.28 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.8 with {\arrow[line width=1.5pt]{<}}}}]
\draw[
  line width=1.5pt,
  my style,
  lightgray,
  rotate=180
] (-0.7,-2.2) -- (-0.7,3.5);
\begin{knot}[
  consider self intersections=true,
  end tolerance=3pt,
  flip crossing=4,
  rotate=180]
  \strand ([closed].5,2) [add arrow,violet] ..  (-.5,1) .. (.3,-.5) .. (-.3,-.5) .. (.5,1) .. ([tension=3]-1.5,1) .. (.7,-1) .. (-2,1);
\end{knot}
\path (0,-.7);
\end{tikzpicture}


\tikzsetnextfilename{large-scale}
\begin{tikzpicture}[scale=2, use Hobby shortcut, add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.25 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.653 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.75 with {\arrow[line width=1.5pt]{<}}}}]
\begin{knot}[
  consider self intersections=true,
  ignore endpoint intersections=false,
  flip crossing=3,
  rotate=180]
  \strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
  \strand[knot diagram/only when rendering/.style={my style}, lightgray] (-0.7,-1.2) -- (-0.7,-.9); 
  \strand[knot diagram/only when rendering/.style={my style}, lightgray] (-0.7,-.75) -- (-0.7,2.5);
\end{knot}
\path (0,-.7);
\end{tikzpicture}

\end{document}

答え2

私はあなたが示唆した通りのことをしました、draft mode=crossingsそしてその後私は6番を横切って反転し、

\documentclass[a4paper,11pt]{report}
\usepackage{graphicx,amssymb,amstext,amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc}

\begin{document}

\tikzset{
  knot diagram/every strand/.append style={
    line width=1.5pt,violet
  },
}

\tikzset{
  my style/.style={
    dashed
  }
}

\begin{tikzpicture}[scale=0.9, use Hobby shortcut, add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.25 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.653 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.75 with {\arrow[line width=1.5pt]{<}}}}]
\begin{knot}[
  consider self intersections=true,
  ignore endpoint intersections=false,
  flip crossing=3,
  rotate=180]
  \strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
  \strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9); 
  \strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
\end{knot}
\path (0,-.7);
\end{tikzpicture}

%---------------------------------------------------------------

\begin{tikzpicture}[scale=2, use Hobby shortcut, add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.25 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.653 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.75 with {\arrow[line width=1.5pt]{<}}}}]
\begin{knot}[%draft mode=crossings,
  consider self intersections=true,
  ignore endpoint intersections=false,
  flip crossing/.list={3,6},
  rotate=180]
  \strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
  \strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9); 
  \strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
\end{knot}
\path (0,-.7);
\end{tikzpicture}

\end{document}

ここに画像の説明を入力してください

わかりました。問題を解決できません。回避策の提案があります。

\documentclass[a4paper,11pt]{report}
\usepackage{graphicx,amssymb,amstext,amsmath}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,decorations.markings,hobby,knots,celtic,shapes.geometric,calc}

\begin{document}

\tikzset{
  knot diagram/every strand/.append style={
    line width=3.2pt,violet
  },
}

\tikzset{
  my style/.style={
    dashed
  }
}

\scalebox{0.45}{
\begin{tikzpicture}[scale=2, use Hobby shortcut, add arrow/.style={postaction={decorate}, decoration={
  markings,
  mark=at position 0.25 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.653 with {\arrow[line width=1.5pt]{<}},
  mark=at position 0.75 with {\arrow[line width=1.5pt]{<}}}}]
\begin{knot}[%draft mode=crossings,
  consider self intersections=true,
  ignore endpoint intersections=false,
  flip crossing=3,
  rotate=180]
  \strand ([closed]0,0) .. (0.7,-0.7) .. (0,-1) .. (-1.7,0) .. (-1.5,2.2) .. (0,2.5) .. (.5,2) .. (-.5,1) [add arrow,violet] .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
  \strand[my style, lightgray] (-0.7,-1.2) -- (-0.7,-.9); 
  \strand[my style, lightgray] (-0.7,-.75) -- (-0.7,2.5);
\end{knot}
\path (0,-.7);
\end{tikzpicture}}

\end{document}

ここに画像の説明を入力してください

関連情報