TikZ Knots 패키지: 스케일링 후 교차가 변경됨

TikZ Knots 패키지: 스케일링 후 교차가 변경됨

내 매듭 다이어그램의 크기가 다르게 조정되면 교차점 중 하나가 변경된다는 것을 깨달았습니다. 횡단보도가 정확해야 합니다.두번째아래 코드로 생성된 다이어그램. 어떻게 이런 일이 일어났는지 모르겠습니다. 사용해봤으나 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 라이브러리의 예기치 않은 동작: 무슨 일이 일어나고 있나요?. 서로 매우 가까운 두 개의 교차점이 있고 클리핑 원(교차점이 그려질 때)이 겹칩니다. 즉, 보라색 선이 회색 점선 위에 그려지면 문제가 있는 교차점에도 그립니다.

다음은 몇 가지 가능한 수정 사항입니다. 먼저 클리핑 원의 반경을 줄입니다. 두 번째에서는 실제로 매듭의 일부가 아닌 것 같아서 매듭에서 회색 점선을 제거했습니다. (매듭을 유지하려면 only when rendering해당 dashed부분에 대한 키를 사용해야 합니다. 자세한 내용은 설명서를 참조하세요.) 세 번째 수정에서는 취미 경로를 조금 단순화했습니다.

결과:

다양한 수정 사항

암호:

\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}

여기에 이미지 설명을 입력하세요

관련 정보