2

It is my first time to try to draw knot in TeX, and I find a a tutorial for drawing knot: https://loopspace.mathforge.org/HowDidIDoThat/TeX/NewKnots/ But I encountered some difficities in trying to understand it.

  1. How does "controls" work in the following code?

    \begin{tikzpicture}
    \path[spath/save=trefoil]
    (0,2) .. controls +(2.2,0) and +(120:-2.2) ..
    (210:2) .. controls +(120:2.2) and +(60:2.2) ..
    (-30:2) .. controls +(60:-2.2) and +(-2.2,0) .. (0,2);
    \tikzset{
    every trefoil component/.style={draw},
    trefoil component 1/.style={blue},
    trefoil component 2/.style={green, dashed, |<->|},
    trefoil component 3/.style={magenta, line width=2pt},
    spath/knot={trefoil}{15pt}{1,3,5},
    }
    \end{tikzpicture}
    

I understand that (0, 2) (210: 2) (-30: 2) are three points in the plane. But what does, for example, controls +(2.2, 0) mean? I tried to draw help lines and I find that +(2.2, 0) does not mean the point (2.2, 0). It makes me confused.

  1. Can I modifiy the following codes to get a figure 8 knot with orientation and labels?
    \begin{tikzpicture}[use Hobby shortcut]
    \path[spath/save=figure8]
    ([closed]0,0) .. (1.5,1) .. (.5,2) ..
    (-.5,1) .. (.5,0) .. (0,-.5) .. (-.5,0) ..
    (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0);
    \tikzset{
    every spath component/.style={draw},
    spath/knot={figure8}{15pt}{1,3,...,7}
    }
    \path (0,-.7);
    \end{tikzpicture}

In this document, the author give a example code of figure 8 knot. But I what to add arrows and labels. It seems I can achieve it to modify the example of trefoil. I thinke If I can really understand how "contros" works in the example of trefoil, combining the coordinates in the example of figure 8, maybe I can draw what I want.

Here is another question related to mine:How do I draw the orientation of a knot in TikZ? But somehow, my computer can't compile the code in it.

The following picture is what I am trying to draw.

enter image description here

Y.Wayne
  • 123
  • 3
  • The syntax +(...) defines relative coordinates, you can find out about them in the TikZ manual. For the second part, it would seem that you are trying to add labels and decorations to a path, which doesn't involve changing the actual path, so you don't need to mess around with the construction. Could you add an image of what you're after? Hand drawn is fine. – Andrew Stacey Mar 23 '22 at 06:40
  • @AndrewStacey Thanks for help, but I still can't understand "(0,2).. controls +(2.2, 0)". If + means relative coordinates, why there is no point (2.2, 2) on the figure? I edit my question and post the picture I want to draw. – Y.Wayne Mar 23 '22 at 07:43
  • The controls part is to do with how tikz constructs paths and is covered in the manual. – Andrew Stacey Mar 23 '22 at 11:57
  • @AndrewStacey Thank you for your advice. After reading the help document, I find a way to draw it. – Y.Wayne Mar 23 '22 at 13:29

1 Answers1

4

Marking the paths with arrows and labels can be done by adding a decoration to the every spath component style. And by using spath component instead of every spath component, we get the label number passed as the #1 argument.

\documentclass{article}
%\url{https://tex.stackexchange.com/q/638097/86}
\usepackage{tikz}
\usetikzlibrary{
  hobby,
  intersections,
  spath3,
  decorations.markings,
  arrows.meta,
}

\begin{document}

\begin{tikzpicture}[use Hobby shortcut] \path[spath/save=figure8] ([closed]0,0) .. (1.5,1) .. (.5,2) .. (-.5,1) .. (.5,0) .. (0,-.5) .. (-.5,0) .. (.5,1) .. (-.5,2) .. (-1.5,1) .. (0,0); \tikzset{ spath component/.style={ draw, postaction={decorate}, decoration={ markings, mark=at position 0.5 with {\arrow{Latex}}, mark=at position 0.5 with { \path (0,0) +(0,1ex) node {(#1)}; }, } }, spath/knot={figure8}{15pt}{1,3,...,7} } \path (0,-.7); \end{tikzpicture}

\end{document}

labelled figure 8 knot

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751