# How to draw BJK continuum in TikZ?

I am a beginner in TikZ. I would like to draw next steps of construction of BJK continuum (buckethandle) in TikZ. I have only contours, but I don't know how to fill them with color. My code:

\documentclass[11pt]{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}[scale=5]

\draw (0,0) -- (1/3,0);
\draw (1,0) arc(0:180:1/2);
\draw (2/3,0) arc(0:180:1/6);
\draw (2/3,0) arc(0:180:1/6);
\draw (1,0) arc(0:-180:1/6);
\end{tikzpicture}

\begin{tikzpicture}[scale=5]
\draw (0,0) -- (1/9,0);
\draw (1,0) arc(0:180:1/2);
\draw (2/3,0) arc(0:180:1/6);
\draw (8/9,0) arc(0:180:7/18);
\draw (8/9,0) arc(0:180:7/18);
\draw (7/9,0) arc(0:180:5/18);
\draw (1,0) arc(0:-180:1/6);
\draw (8/9,0) arc(0:-180:1/18);
\draw (1/3,0) arc(0:-180:1/18);
\end{tikzpicture}

\begin{tikzpicture}[scale=5]
\draw (0,0) -- (1/27,0);
\draw (1,0) arc(0:180:1/2);
\draw (26/27,0) arc(0:180:25/54);
\draw (25/27,0) arc(0:180:23/54);
\draw (24/27,0) arc(0:180:21/54);
\draw (2/3,0) arc(0:180:1/6);
\draw (19/27,0) arc(0:180:11/54);
\draw (20/27,0) arc(0:180:13/54);
\draw (21/27,0) arc(0:180:15/54);
\draw (1,0) arc(0:-180:1/6);
\draw (26/27,0) arc(0:-180:7/54);
\draw (25/27,0) arc(0:-180:5/54);
\draw (24/27,0) arc(0:-180:1/18);
\draw (1/3,0) arc(0:-180:1/18);
\draw (8/27,0) arc(0:-180:1/54);
\draw (1/9,0) arc(0:-180:1/54);
\end{tikzpicture}

\end{document}


This should be like in the picture below. How I can do that?

• Welcome! You want help with the next steps, so could you show us the code for your steps so far? – cfr Aug 12 '16 at 22:21
• I don't know how to draw in tikz so I don't have any steps. I thought to draw plots of circles, but I have no idea how to fill color the area between this plots so as to get this buckethandle. – Mayers Aug 13 '16 at 15:59
• Do you need LaTeX to compute everything or do you have the data (arc centers and radii) available? – Christoph Frings Aug 13 '16 at 16:48
• I only have a description of the general structure. We have B_0 - set of all closed semicircles in the upper half plane centered on c_0=1/2 whose diameters have enpoints in the Cantor middle third set. Let B_0' denote the reflection of B_0 about the x-axis. For 1 ≤ n, let B_n=c_n-c_0+B_0'/3^n, where c_n=2.5/3^n. Then K=B_0 ∪ B_1 ∪ B_2 ∪ · · · is a buckethandle. – Mayers Aug 13 '16 at 17:51
• Would simply filling the shapes alternating between blue and white be a solution? \documentclass[11pt]{article} \usepackage{pgfplots} \pgfplotsset{compat=1.13} \begin{document} \begin{tikzpicture}[scale=5] \draw (0,0) -- (1/3,0); \draw[fill=blue] (1,0) arc(0:180:1/2); \draw[fill=white] (2/3,0) arc(0:180:1/6); \draw[] (2/3,0) arc(0:180:1/6); \draw[fill=blue] (1,0) arc(0:-180:1/6); \end{tikzpicture} \end{document} ? – user36296 Aug 14 '16 at 12:08

# Iterative version

Five iterations with a complete iterative solution:

\documentclass[tikz,margin=0mm]{standalone}
\gdef\curarcs{180/0/1/-2}
\gdef\den{2}
\def\nextiter{
\gdef\startarcs{}
\gdef\nedarcs{}
\pgfmathtruncatemacro\nden{\den*3}
\xdef\den{\nden}
\foreach \sa/\ea/\num/\mod[count=\c] in \curarcs {
\pgfmathtruncatemacro\snnum{\num*3}
\pgfmathtruncatemacro\ennum{\num*3+\mod}
\pgfmathtruncatemacro\enmod{-\mod}
\pgfmathtruncatemacro\snmod{\mod}
\edef\snarc{\sa/\ea/\snnum/\snmod}
\edef\enarc{\ea/\sa/\ennum/\enmod}
\ifnum\c=1 \xdef\startarcs{\snarc} \else \xdef\startarcs{\startarcs,\snarc} \fi
\ifnum\c=1 \xdef\endarcs{\enarc} \else \xdef\endarcs{\enarc,\endarcs} \fi
}
\xdef\curarcs{\startarcs,0/-180/1/-2,\endarcs}
}
\begin{document}
\foreach \iter in {1,...,5}{
\begin{tikzpicture}
\nextiter
\path[fill=red] (0,0)
\foreach \sa/\ea/\num/\mod in \curarcs { arc(\sa:\ea:\num/\den) }
-- cycle;
\end{tikzpicture}
}
\end{document}


# Initial version

Here are four iterations... and some comments to show the recursive procedure.

\documentclass[tikz]{standalone}
\begin{document}

\begin{tikzpicture}
\fill[blue]
(0,0)
arc(180:0:3/6)
%
arc(0:-180:1/6)
%
arc(0:180:1/6)   % -2
-- cycle;
\end{tikzpicture}

\begin{tikzpicture}
\fill[blue]
(0,0)
arc(180:0:9/18)
arc(0:-180:3/18)
arc(0:180:3/18)
%
arc(0:-180:1/18)
%
arc(180:0:5/18)  % +2
arc(-180:0:1/18) %% -2
arc(0:180:7/18)  % -2
-- cycle;
\end{tikzpicture}

\begin{tikzpicture}
\fill[blue]
(0,0)
arc(180:0:27/54)
arc(0:-180:9/54)
arc(0:180:9/54)
arc(0:-180:3/54)
arc(180:0:15/54)
arc(-180:0:3/54)
arc(0:180:21/54)
%
arc(0:-180:1/54)
%
arc(180:0:23/54) % +2
arc(0:-180:5/54) % +2
arc(0:180:13/54) % -2
arc(-180:0:1/54) %% -2
arc(180:0:11/54) % +2
arc(-180:0:7/54) % -2
arc(0:180:25/54) % -2
-- cycle;
\end{tikzpicture}

\begin{tikzpicture}
\fill[blue]
(0,0)
arc(180:0:81/162)
arc(0:-180:27/162)
arc(0:180:27/162)
arc(0:-180:9/162)
arc(180:0:45/162)
arc(-180:0:9/162)
arc(0:180:63/162)
arc(0:-180:3/162)
arc(180:0:69/162)
arc(0:-180:15/162)
arc(0:180:39/162)
arc(-180:0:3/162)
arc(180:0:33/162)
arc(-180:0:21/162)
arc(0:180:75/162)
%
arc(0:-180:1/162)
%
arc(180:0:77/162)  % +2
arc(0:-180:23/162) % +2
arc(0:180:31/162)  % -2
arc(0:-180:5/162)  % +2
arc(180:0:41/162)  % +2
arc(-180:0:13/162) % -2
arc(0:180:67/162)  % -2
arc(-180:0:1/162)  %% -2
arc(180:0:65/162)  % +2
arc(0:-180:11/162) % +2
arc(0:180:43/162)  % -2
arc(-180:0:7/162)  % -2
arc(180:0:29/162)  % +2
arc(-180:0:25/162) % -2
arc(0:180:79/162)  % -2
-- cycle;
;
\end{tikzpicture}

\end{document}


Each step starts with the same path than previous step (with a denominator three times larger). Then you get an arc with a radius of 1/denominator. Then you revert the first part of the path with numerators of radii slightly modified (by 2 or -2). All the modifications (2 or -2) are symmetric (but opposed), the central modification is always -2 and the last part of the modifications is the same than in the previous step.

There are dedicated libraries for such problems, like \usepgfplotslibrary{fillbetween} and similar, but for such a simple example it might be sufficient to alternate the filling between white and blue:

\documentclass[11pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\begin{document}
\begin{tikzpicture}[scale=5]
\draw (0,0) -- (1/3,0);
\draw[fill=blue] (1,0) arc(0:180:1/2);
\draw[fill=white] (2/3,0) arc(0:180:1/6);
\draw[] (2/3,0) arc(0:180:1/6);
\draw[fill=blue] (1,0) arc(0:-180:1/6);
\end{tikzpicture}
\end{document}