TikZ – Making a Labeled Klein Bottle Using TikZ or PGFplots

3dpgfplotstikz-pgf

I'd like to be able to draw the following cell complex structure on the (three-dimensional embedding of the) Klein bottle using LaTeX. I am pretty pleased with my hand-drawn rendition, but LaTeX is prettier, and can be edited.

enter image description here

I am still in the process of learning TikZ, and I have not used the pgfplots package before, so I don't know if it can help. The only places I found online that seemed related were


Edit: Thanks to hpesoj626's helpful comment below, I have got gnuplots working, so I can compile at least the second example above now (I still don't know how to implement the first one). However, there is still the issue of decorating the Klein bottle with the various curves and points I want to draw, which neither post addresses.

Also, both plotting solutions seem to be too "heavy", visually, to really make labeling them in the way I want seem viable. I am looking for more of an outline-looking Klein bottle. If the ultimate answer is that I need to draw it out "by hand" (i.e. plan out a 2-dimensional image representing the Klein bottle), then please post any advice you have about how to go about doing that.

Can anyone suggest a method of drawing this in LaTeX?

Best Answer

Further explanations will follow, for now so much:

  • put your sketch in a node
  • recreate the lines using draw commands (I used to[in=,out=,looseness=])
  • remove the sketch

It's far from perfect, somee labels are missing. You can increase the quality ba adding more intermediate points.

(Final) Code

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}

\usepackage{tikz}
\usetikzlibrary{scopes,intersections}

\newcommand{\Coordinate}[2]%
{ \coordinate (#1) at (#2);
    %\fill[red] (#2) circle (0.05) node[above] {#1};
}

\begin{document}

\begin{frame}

\begin{tikzpicture}
%   \node[above right,inner sep=0,outer sep=0] (a) {\includegraphics{klein.png}};
%   \draw[orange,thin,dashed,] (a.south west) grid (a.north east);
%   \foreach \x in {0,...,10}{\node [below] at (\x,0) {\x};}
%   \foreach \y in {0,...,12}{\node [left] at (0,\y) {\y};}

    \node[fill=blue,circle,label=0:P1,inner sep=0.5mm] (P1) at (4.9,6.7) {};
    \node[fill=blue,circle,label=270:P2,inner sep=0.5mm] (P2) at (2.5,5.4) {};
    \node[fill=blue,circle,label=45:P3,inner sep=0.5mm] (P3) at (1.6,4) {};
    \Coordinate{e5b}{3.6,1.3}
    \Coordinate{e4l}{0.7,4.8}
    \Coordinate{e4r}{9.9,3.7}
    \Coordinate{si}{4.5,7.4}
    \Coordinate{bottom}{6.8,0.9}

    {[very thick,black]
        \draw (e4l) to[out=270,in=160,looseness=1] (P3);
        \draw (P3) to[out=340,in=270,looseness=0.3] node[above,pos=0.7,black] {$e_4$} (e4r);
        \draw[name path=P2e4r] (P2) to[out=120,in=80,looseness=3.7] node[below left,pos=0.7,black] {$f_2$} (e4r);
        \draw[name path=P1P1] (P1) to[out=160,in=270,looseness=1] (2.6,9) to[out=90,in=90,looseness=1.3] node[above, pos=0.5,black] {$e_3$} (6.6,9.6) to[out=270,in=40,looseness=1]  (P1) ;
        \draw (P2) to[out=315,in=315,looseness=0.5] node[below right,pos=0.5,black] {$e_1$} (P1);
        \draw[dashed] (P2) to[out=135,in=135,looseness=0.5] node[below right,pos=0.5,black] {$f_1$} (P1);
        \draw (P2) to[out=220,in=90,looseness=1] (P3);
        \draw (P3) to[out=270,in=150,looseness=1] (e5b);
        \draw (e4l) to[out=270,in=160,looseness=1.3] (e5b);
        \draw (e5b) to[out=340,in=260,looseness=1.1] (e4r);
        \draw[dashed] (P2) to[out=300,in=330,looseness=1] (e5b);
        \draw[dashed] (e4l) to[out=90,in=90,looseness=0.6] (e4r);
        \draw[dashed] (P1) to[out=320,in=190,looseness=0.4] (bottom);
        \draw (P1) to[out=110,in=300,looseness=1] (si);

        \draw (si) to[out=120,in=270,looseness=1] (4,8.5) to[out=90,in=180,looseness=1] (5.2,9.7) to[out=0,in=90,looseness=1] (6,9) to[out=270,in=20,looseness=1] (si);

        \path[name path=e4lsi] (e4l) to[out=90,in=200,looseness=0.8] (si);
        \draw[name intersections={of=e4lsi and P2e4r}] (e4l) to[out=90,in=210,looseness=1] (intersection-1) coordinate (h1);
        \draw[dashed] (intersection-1) to[out=30,in=200,looseness=0.6] (si);
    }
\end{tikzpicture}

\end{frame}

\end{document}

Output

enter image description here

Related Question