Tikz : self intersection not recognized in knots library of spath3
As you say, it is the end tolerance
parameter that is at stake. But, I redefined your path because its departure and arrival use uselessly beziers curves to draw straight lines. This way I get the result you want.
\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{calc,knots}
%set default length and width parameters
\def\x{.7}
\def\y{1}
\begin{document}
\begin{tikzpicture}
\begin{knot}[consider self intersections,end tolerance=.01pt,
%draft mode=crossings
]
\strand (0,-\y) %.. controls +(0,0) <-- useless beziers curve
%..
--(0,0) .. controls +(0,\x/3) and +(0,\x/3)
.. (\x/2,0) .. controls +(0,-\x/3) and +(0,-\x/3)
.. (0,0) %.. controls +(0,0) .. <- useless beziers curve
--(0,\y);
\end{knot}
\end{tikzpicture}
\end{document}
LoopSpace explained very well what the issue is, and how to fix it. Here I'd like to draw your attention to an alternative, which has been used in a very similiar application. This alternative is by no means "better" than, or even comparable to, the knots
package. The reason why I am mentioning it here is that it gives a rather reasonable output without the need modify your path, or to tune parameters.
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[rubout/.style={/utils/exec=\tikzset{rubout/.cd,#1},
decoration={show path construction,
curveto code={
\draw [white,line width=\pgfkeysvalueof{/tikz/rubout/line width}+2*\pgfkeysvalueof{/tikz/rubout/halo}]
(\tikzinputsegmentfirst) .. controls
(\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast);
\draw [line width=\pgfkeysvalueof{/tikz/rubout/line width},shorten <=-0.1pt,shorten >=-0.1pt] (\tikzinputsegmentfirst) .. controls
(\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb) ..(\tikzinputsegmentlast);
}}},rubout/.cd,line width/.initial=0.6pt,halo/.initial=0.6pt]
\def\x{.7}
\def\y{1}
\draw[rubout,decorate] (0,-\y) .. controls +(0,0)
.. (0,0) .. controls +(0,\x/3) and +(0,\x/3)
.. (\x/2,0) .. controls +(0,-\x/3) and +(0,-\x/3)
.. (0,0) .. controls +(0,0) .. (0,\y);\end{tikzpicture}
\end{document}
Thanks for all the answers !
Following the suggestion of Loop Space I created a more stable variant by slightly deviating from the initial picture. I also realized that, for this picture, using arc
instead of beziers curves keeps the code more readable, but that's just taste I guess.
\documentclass[tikz, border=5mm]{standalone}
\usetikzlibrary{calc,knots}
% basic distances for tikz
\def\y{1}
\def\r{-.2}
\begin{document}
\begin{tikzpicture}
\begin{knot}[consider self intersections, end tolerance=1pt]
\strand (0,-\y) to (0,0) arc (0:90:\r) arc (90:270:\r*.6) arc (270:360:\r)
to (0,\y);
\end{knot}
\end{tikzpicture}
\end{document}