1

I'm new to the knots library for TikZ and I have problems drawing some simple knots. With the MWE below, the library claims there are 12 crossings although in reality there are only four. Furthermore, some of the crossings receive more than one number and I can't figure out how to reliably control the flipping. \flipcrossings{2} doesn't seem to have any effect on the crossing numbered 2 while \flipcrossings{9} does. I guess this is because 9 is the highest number this particular crossing got, but that's not easy to see as there are several numbers atop each other.

I tried other options for the knot environment and I also tried other ways to draw the strand (for example with to or with Bézier curves instead of Hobby curves) but that doesn't seem to solve the problem.

What am I doing wrong?

\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{knots,hobby}
\begin{document}
\begin{tikzpicture}
  \begin{knot}[draft mode=crossings,consider self intersections=no splits,ignore endpoint intersections=false]
    \strand[closed hobby] plot coordinates {(2.5,5) (2.5,2) (2.5,0.5) (0.5,2.5) (2.5,4) (4.5,2.5) (2.5,0.5) (2.5,2)};
  \end{knot}
\end{tikzpicture}
\end{document}

FWIW, this is what I see (MiKTeX on Windows, updated today):

Wrong crossing count

1 Answer 1

1

I rummaged around a bit more and found a comment from Andrew Stacey (the package author) here where he says:

The algorithm behind the knots package works best when the crossing is not at the endpoint of a section of the path.

So, I modified my curve a bit and now it works (except for the pseudo-crossing at the start which doesn't hurt):

\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{knots,hobby}
\begin{document}
\begin{tikzpicture}
  \begin{knot}[draft mode=crossings,consider self intersections=no splits,ignore endpoint intersections=false]
    \strand[closed hobby] plot coordinates {(2.5,5) (1.6,4) (2.75,1.2) (2,0.2) (0.5,2.5) (2.5,4) (4.5,2.5) (3,0.2) (2.25,1.2) (3.4,4)};
  \end{knot}
\end{tikzpicture}
\end{document}

How it looks

2
  • That would have been one of my suggestions to try. The other was to use ignore endpoint intersections=true. When considering a self-intersecting curve then the algorithm has to split the curve into pieces and it tries to ignore the fact that one segments "intersects" the next at their mutual endpoints. The key ignore endpoint intersections controls this. Nov 9, 2022 at 22:44
  • @AndrewStacey Thanks. I had tried that, but then the algorithm misses two crossings completely.
    – Frunobulax
    Nov 10, 2022 at 7:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .