In the process of typing up a set of lecture notes for a course, I found myself in need of a nice picture of a torus knot, which basically comes down to drawing a very complicated line. With some trickery, I was able to produce the simplest such knot, which is not even really a knot (but it's a start...). The code is as follows:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=2]
\draw (-3.5,0) .. controls (-3.5,1.2) and (-1.5,1.5) .. (0,1.5);
\draw[xscale=-1] (-3.5,0) .. controls (-3.5,1.2) and (-1.5,1.5) .. (0,1.5);
\draw[rotate=180] (-3.5,0) .. controls (-3.5,1.2) and (-1.5,1.5) .. (0,1.5);
\draw[yscale=-1] (-3.5,0) .. controls (-3.5,1.2) and (-1.5,1.5) .. (0,1.5);
\draw (-2,.2) .. controls (-1.5,-0.05) and (-1,-0.15) ..
(0,-.15) .. controls (1,-0.15) and (1.5,-0.05) .. (2,0.2);
\draw (-1.7,0.1) .. controls (-1.5,0.15) and (-1,0.25) ..
(0,.25) .. controls (1,0.25) and (1.5,0.15) .. (1.7,0.1);
\begin{scope}[rotate=10]
\draw[draw=none] (0,-1.32) arc (270:630:3.06cm and 1.32cm)
coordinate[pos=0.375] (a) coordinate[pos=0.875] (b);
\draw[red] (0,-1.32) arc (270:405:3.06cm and 1.32cm);
\draw[red,densely dashed] (a) arc (45:225:3.06cm and 1.32cm);
\draw[red] (b) arc (225:270:3.06cm and 1.32cm);
\end{scope}
\end{tikzpicture}
\end{document}
and the output is:
However, I'm also interested in being able to produce a picture of nontrivial knots such as a loop that wraps around one way three times while "going around the hole" once, and my method does not generalize. My question, therefore, is: Is it possible to efficiently produce pictures such as these (one may also think of natural generalizations like lines on surfaces of arbitrary genus), using TikZ? I should add that I already have a way of efficiently producing a picture of any (compact) orientable surface (without boundary, up to homotopy equivalence---I'm typing notes for an algebraic topology class): It's just the lines on them that I don't know how to quickly draw.
This is a related, yet much simpler question (not a duplicate).