blob: 3e781bd21e16be264badf8f00fd779f1c7809374 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
\title{Hilbert Curves}
\author{}
\date{}
\documentclass{tufte-handout}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\usetikzlibrary{lindenmayersystems,positioning}
\begin{document}
\pgfdeclarelindenmayersystem{Hilbert curve}{
\symbol{X}{\pgflsystemdrawforward}
\symbol{+}{\pgflsystemturnright} % Explicitly define + and - symbols.
\symbol{-}{\pgflsystemturnleft}
\rule{A -> +BX-AXA-XB+}
\rule{B -> -AX+BXB+XA-}
}
\def\scalefac{0.6}
% Draw a hilbert curve of order n
% Usage:
% \hilbertvurve[scale]{order}
\newcommand\hilbertcurve[2][1]{
\tikz \draw[scale=\scalefac*#1,rotate=90,lindenmayer system={Hilbert curve, axiom=A, order=#2,angle=90}]
lindenmayer system;
}
\maketitle
\begin{figure}[h!]
\begin{tikzpicture}[node distance=0cm,every path/.style={thin}]
\node[label={above:$n=1$}] (n1) {\hilbertcurve[18]{1}};
\node[label={above:$n=2$},right=of n1] (n2) {\hilbertcurve[6]{2}};
\node[label={above:$n=3$},right=of n2] (n3) {\hilbertcurve[2.6]{3}};
\node[label={above:$n=4$},right=of n3] (n4) {\hilbertcurve[1.2]{4}};
\node[label={above:$n=5$},right=of n4] (n5) {\hilbertcurve[0.58]{5}};
\end{tikzpicture}
\end{figure}
\end{document}
|