5

When I tried to come up with an answer to this question, I observed a strange behaviour of TikZ’s knots library. Or maybe it is not strange at all and I just overlooked something ...

Take this code:

\documentclass[tikz, border=0mm]{standalone}

\usetikzlibrary{knots, decorations.markings}

\begin{document}
\begin{tikzpicture}[
    arrowmark/.style={draw=red, only when rendering/.style={postaction=decorate}}
]

\begin{knot}[
  clip width=3,
]

%\strand (0,0) ellipse (20pt and 10pt);                                          <-- uncomment for second image
\strand (0:20pt) arc (0:180:20pt and 10pt) arc (180:0:20pt and -10pt) -- cycle;  <-- comment out for second image

\strand (0:1cm+20pt) arc (0:180:20pt and 20pt) arc (180:0:20pt and -20pt) -- cycle;
\strand[arrowmark, decoration={markings, mark=at position 0.5 with {\arrow{>}}}] (1,-1.5) .. controls (1.8,0.2) and (0.2,0.2) .. (1,-1.5);
\strand[arrowmark, decoration={markings, mark=at position 0.45 with {\arrow{>}}}] (1,-1.5) to[out=180, in=0] (-.5,0) .. controls (-1.25,0) and (-.75,-1.5) .. (1,-1.5);

%\flipcrossings{1,2,5}                                                           <-- uncomment for second image
\flipcrossings{1,4,6}                                                            <-- comment out for second image

\end{knot}

\filldraw [red] (1,-1.5) circle (1pt);

\end{tikzpicture}
\end{document}

It renders nicely as follows:

enter image description here

Now uncomment the two commented lines and comment out the two following lines instead (as indicated in the above code), then you (or at least I) will get (without the yellow highlighting, of course):

enter image description here

As can be cleary seen, the intersection of the rightmost red curl with the ellipse is not what I expect it to be. When I used two ellises originally, I had the same problem. I first thought that using an ellipse might be causing this. If I add the option draft mode=crossings, the relevant intersection seems to be not identified at all. I was unable to find something about this problem in the relevant documentation.

Actually one nice answer to the above linked questions also uses quite the same approach. There it seems to work with two ellises and two open paths. What is the difference here?

0

1 Answer 1

6

I found the answer by myself. Just in case someone has a similar problem, I will still post it here.

The reason why the knots library may ignore some intersections is obviously that they are too close to the end points of paths. It is possible to correct this using the option end tolerance.

In this case here, this tolerance should be very low, since the distance between the relevant intersection and the end and start point of the ellipse (which is at the very bottom of the path) happen to be almost at the same coordinate.

\documentclass[tikz, border=0mm]{standalone}

\usetikzlibrary{knots, decorations.markings}

\begin{document}
\begin{tikzpicture}[
    arrowmark/.style={draw=red, only when rendering/.style={postaction=decorate}}
]

\begin{knot}[
  draft mode=crossings,
  end tolerance=1pt,
  clip width=3,
]

\strand (0,0) ellipse (20pt and 10pt);
%\strand (0:20pt) arc (0:180:20pt and 10pt) arc (180:0:20pt and -10pt) -- cycle;  <

\strand (0:1cm+20pt) arc (0:180:20pt and 20pt) arc (180:0:20pt and -20pt) -- cycle;

\strand[arrowmark, decoration={markings, mark=at position 0.5 with {\arrow{>}}}] (1,-1.5) .. controls (1.8,0.2) and (0.2,0.2) .. (1,-1.5);

\strand[arrowmark, decoration={markings, mark=at position 0.45 with {\arrow{>}}}] (1,-1.5) to[out=180, in=0] (-.5,0) .. controls (-1.25,0) and (-.75,-1.5) .. (1,-1.5);

\flipcrossings{1,4,6}

\end{knot}

\filldraw [red] (1,-1.5) circle (1pt);

\end{tikzpicture}
\end{document}

enter image description here

Without specifying the option end tolerance: enter image description here

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.