diff --git a/tikz/arbelos/Makefile b/tikz/arbelos/Makefile new file mode 100644 index 0000000..850026f --- /dev/null +++ b/tikz/arbelos/Makefile @@ -0,0 +1,25 @@ +SOURCE = arbelos +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/arbelos/arbelos.tex b/tikz/arbelos/arbelos.tex new file mode 100644 index 0000000..e774165 --- /dev/null +++ b/tikz/arbelos/arbelos.tex @@ -0,0 +1,42 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + + % Draw A + \coordinate[label=left:$A$] (A) at (0,0); + + % Draw the Arbelos + \begin{scope}[shift={(4,0)}, scale=4] + \draw[fill=green!30, thick](-1,0) + arc (180:0:1) + arc (0:180:0.25) + arc (0:180:0.75); + \end{scope} + + \begin{scope}[shift={(4,0)}] + % Draw D + \coordinate[label=below:$D$] (D) at (2,0); + + % Perpendicular CD + \draw[thick] (2,0) -- node[] {} (2,3.47); + + % Draw C + \coordinate[label=above:$C$] (C) at (2,3.47); + \end{scope} + + % Draw B + \coordinate[label=below:$B$] (B) at (8,0); + + % Cirlce CD + \draw[thick] (6,1.735) circle (1.735cm); + + % Bottom line AB + \draw[thick] (0,0) -- node[] {} (8,0); + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/arc/Makefile b/tikz/arc/Makefile new file mode 100644 index 0000000..12f6b44 --- /dev/null +++ b/tikz/arc/Makefile @@ -0,0 +1,31 @@ +SOURCE = arc +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/arc/arc.tex b/tikz/arc/arc.tex new file mode 100644 index 0000000..353d9cb --- /dev/null +++ b/tikz/arc/arc.tex @@ -0,0 +1,43 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{shapes, calc, shapes,snakes} +\usepackage{amsmath,amssymb} + +\begin{document} +\begin{preview} +\resizebox{250px}{250px}{ +\begin{tikzpicture}[] + \newcommand\R{1.3cm} + + \draw[fill=gray!2] (0,0) circle (\R); + + % draw the background + \draw [line width=0.1pt, fill=gray!10] + (0,0) -- + (170: \R) -- + (45:\R) -- cycle; + + \begin{scope}[color=green] + \draw[fill=green!15] (0,0) -- + (170:{\R*0.3}) arc (170:45:{{(\R)*0.3}}); + \end{scope} + + % Kreisbogen + \begin{scope}[thick, color=red] + \draw[] (170:\R) arc (170:45:\R); + \end{scope} + + % Winkel + \draw[] (0,0) -- (170:\R); + \draw[] (0,0) -- (45:\R); + \draw[thick, color=blue] (170:\R) -- (45:\R); + + % draw alpha + \coordinate[label=$\alpha$] (Alpha) at (-{\R/20}, 0); + \coordinate[label=$r$] (Alpha) at ({\R/2}, {\R/5}); +\end{tikzpicture} +} +\end{preview} +\end{document} diff --git a/tikz/array/Makefile b/tikz/array/Makefile new file mode 100644 index 0000000..ed0bfdf --- /dev/null +++ b/tikz/array/Makefile @@ -0,0 +1,31 @@ +SOURCE = array +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/array/array.tex b/tikz/array/array.tex new file mode 100644 index 0000000..2f067ea --- /dev/null +++ b/tikz/array/array.tex @@ -0,0 +1,25 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{shapes.multipart, calc} + +\begin{document} +\begin{preview} +\begin{tikzpicture}[array/.style={rectangle split,rectangle split horizontal, rectangle split parts=#1,draw, anchor=center, fill=white}] +\node[array=5] (a) { +\nodepart{one}d +\nodepart{two} +\nodepart{three}c +\nodepart{four}c +\nodepart{five}b +}; +\node[color=gray, anchor=north, yshift=-0.5] at (a.one) {\tiny $0$}; +\node[color=gray, anchor=north, yshift=-2] at (a.two) {\tiny $1$}; +\node[color=gray, anchor=north, yshift=-2] at (a.three) {\tiny $2$}; +\node[color=gray, anchor=north, yshift=-2] at (a.four) {\tiny $3$}; +\node[color=gray, anchor=north, yshift=-0.5] at (a.five) {\tiny $4$}; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/b-tree-2-small-2/Makefile b/tikz/b-tree-2-small-2/Makefile new file mode 100644 index 0000000..015b48e --- /dev/null +++ b/tikz/b-tree-2-small-2/Makefile @@ -0,0 +1,31 @@ +SOURCE = b-tree-2-small-2 +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/b-tree-2-small-2/b-tree-2-small-2.tex b/tikz/b-tree-2-small-2/b-tree-2-small-2.tex new file mode 100644 index 0000000..1d5a2e8 --- /dev/null +++ b/tikz/b-tree-2-small-2/b-tree-2-small-2.tex @@ -0,0 +1,75 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{calc,shapes.multipart,chains,arrows,positioning} + +\tikzset{ + font=\tt, + >= stealth, + every picture/.style={thick}, + pointer/.style={*->}, + node/.style={ + align=center, + rectangle split, rectangle split horizontal, + rectangle split parts=#1, + draw, + anchor=center, + rectangle split part align={center}, + rectangle split empty part width=1.5, + rectangle split part fill = {white} + } +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (3,3){ + \tikz \node[node=5] (A) { + \nodepart{one} + \nodepart{two}7 + \nodepart{three} + \nodepart{four}11 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (0,0){ + \tikz \node[node=5] (B) { + \nodepart{one} + \nodepart{two}1 + \nodepart{three} + \nodepart{four}4 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (3,0){ + \tikz \node[node=5] (C) { + \nodepart{one} + \nodepart{two}4 + \nodepart{three} + \nodepart{four}8 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (6.7,0){ + \tikz \node[node=7, rectangle split part fill={red, white, green, white, blue, white, purple}] (D) { + \nodepart{one} + \nodepart{two}14 + \nodepart{three} + \nodepart{four}15 + \nodepart{five} + \nodepart{six}16 + \nodepart{seven} + }; + }; + + \draw[pointer] (1.9, 3.1) -- ($(B)+(0,0.4)$) node[] {}; + \draw[pointer] (2.8, 3.1) -- ($(B)+(2.8,0.4)$) node[] {}; + \draw[pointer] (3.9, 3.1) -- ($(B)+(6,0.4)$) node[] {}; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/b-tree-2-small-3/Makefile b/tikz/b-tree-2-small-3/Makefile new file mode 100644 index 0000000..f7af1d2 --- /dev/null +++ b/tikz/b-tree-2-small-3/Makefile @@ -0,0 +1,31 @@ +SOURCE = b-tree-2-small-3 +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/b-tree-2-small-3/b-tree-2-small-3.tex b/tikz/b-tree-2-small-3/b-tree-2-small-3.tex new file mode 100644 index 0000000..fade4a2 --- /dev/null +++ b/tikz/b-tree-2-small-3/b-tree-2-small-3.tex @@ -0,0 +1,82 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{calc,shapes.multipart,chains,arrows,positioning} + +\tikzset{ + font=\tt, + >= stealth, + every picture/.style={thick}, + pointer/.style={*->}, + node/.style={ + align=center, + rectangle split, rectangle split horizontal, + rectangle split parts=#1, + draw, + anchor=center, + rectangle split part align={center}, + rectangle split empty part width=1.5, + rectangle split part fill = {white} + } +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (3,3){ + \tikz \node[node=7] (A) { + \nodepart{one} + \nodepart{two}7 + \nodepart{three} + \nodepart{four}11 + \nodepart{five} + \nodepart{six}15 + \nodepart{seven} + }; + }; + + \node[align=center, draw, fill=yellow] at (0,0){ + \tikz \node[node=5] (B) { + \nodepart{one} + \nodepart{two}1 + \nodepart{three} + \nodepart{four}4 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (3,0){ + \tikz \node[node=5] (C) { + \nodepart{one} + \nodepart{two}4 + \nodepart{three} + \nodepart{four}8 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (5.6,0){ + \tikz \node[node=3, rectangle split part fill={red, white, green}] (D) { + \nodepart{one} + \nodepart{two}14 + \nodepart{three} + }; + }; + + \node[align=center, draw, fill=yellow] at (7.8,0){ + \tikz \node[node=3, rectangle split part fill={blue, white, purple}] (D) { + \nodepart{one} + \nodepart{two}16 + \nodepart{three} + }; + }; + + \draw[pointer] (1.4, 3.1) -- ($(B)+(0,0.4)$) node[] {}; + \draw[pointer] (2.25, 3.1) -- ($(B)+(3,0.4)$) node[] {}; + \draw[pointer] (3.3, 3.1) -- ($(B)+(5.6,0.4)$) node[] {}; + \draw[pointer] (4.4, 3.1) -- ($(B)+(7.8,0.4)$) node[] {}; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/b-tree-2-small-4/Makefile b/tikz/b-tree-2-small-4/Makefile new file mode 100644 index 0000000..2d69f41 --- /dev/null +++ b/tikz/b-tree-2-small-4/Makefile @@ -0,0 +1,31 @@ +SOURCE = b-tree-2-small-4 +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/b-tree-2-small-4/b-tree-2-small-4.tex b/tikz/b-tree-2-small-4/b-tree-2-small-4.tex new file mode 100644 index 0000000..a5c3900 --- /dev/null +++ b/tikz/b-tree-2-small-4/b-tree-2-small-4.tex @@ -0,0 +1,84 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{calc,shapes.multipart,chains,arrows,positioning} + +\tikzset{ + font=\tt, + >= stealth, + every picture/.style={thick}, + pointer/.style={*->}, + node/.style={ + align=center, + rectangle split, rectangle split horizontal, + rectangle split parts=#1, + draw, + anchor=center, + rectangle split part align={center}, + rectangle split empty part width=1.5, + rectangle split part fill = {white} + } +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (3,3){ + \tikz \node[node=7] (A) { + \nodepart{one} + \nodepart{two}7 + \nodepart{three} + \nodepart{four}11 + \nodepart{five} + \nodepart{six}15 + \nodepart{seven} + }; + }; + + \node[align=center, draw, fill=yellow] at (0,0){ + \tikz \node[node=5] (B) { + \nodepart{one} + \nodepart{two}1 + \nodepart{three} + \nodepart{four}4 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (3,0){ + \tikz \node[node=5] (C) { + \nodepart{one} + \nodepart{two}4 + \nodepart{three} + \nodepart{four}8 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (5.6,0){ + \tikz \node[node=3, rectangle split part fill={red, white, green}] (D) { + \nodepart{one} + \nodepart{two}14 + \nodepart{three} + }; + }; + + \node[align=center, draw, fill=yellow] at (8.4,0){ + \tikz \node[node=5, rectangle split part fill={blue, white, purple, white}] (D) { + \nodepart{one} + \nodepart{two}16 + \nodepart{three} + \nodepart{four}17 + \nodepart{five} + }; + }; + + \draw[pointer] (1.4, 3.1) -- ($(B)+(0,0.4)$) node[] {}; + \draw[pointer] (2.25, 3.1) -- ($(B)+(3,0.4)$) node[] {}; + \draw[pointer] (3.3, 3.1) -- ($(B)+(5.6,0.4)$) node[] {}; + \draw[pointer] (4.4, 3.1) -- ($(B)+(8.4,0.4)$) node[] {}; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/b-tree-2-small/Makefile b/tikz/b-tree-2-small/Makefile new file mode 100644 index 0000000..7f1fe7d --- /dev/null +++ b/tikz/b-tree-2-small/Makefile @@ -0,0 +1,31 @@ +SOURCE = b-tree-2-small +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/b-tree-2-small/b-tree-2-small.tex b/tikz/b-tree-2-small/b-tree-2-small.tex new file mode 100644 index 0000000..3fa680a --- /dev/null +++ b/tikz/b-tree-2-small/b-tree-2-small.tex @@ -0,0 +1,73 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{calc,shapes.multipart,chains,arrows,positioning} + +\tikzset{ + font=\tt, + >= stealth, + every picture/.style={thick}, + pointer/.style={*->}, + node/.style={ + align=center, + rectangle split, rectangle split horizontal, + rectangle split parts=#1, + draw, + anchor=center, + rectangle split part align={center}, + rectangle split empty part width=1.5, + rectangle split part fill = {white} + } +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (3,3){ + \tikz \node[node=5] (A) { + \nodepart{one} + \nodepart{two}7 + \nodepart{three} + \nodepart{four}11 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (0,0){ + \tikz \node[node=5] (B) { + \nodepart{one} + \nodepart{two}1 + \nodepart{three} + \nodepart{four}4 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (3,0){ + \tikz \node[node=5] (C) { + \nodepart{one} + \nodepart{two}4 + \nodepart{three} + \nodepart{four}8 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (6.2,0){ + \tikz \node[node=5] (D) { + \nodepart{one} + \nodepart{two}14 + \nodepart{three} + \nodepart{four}15 + \nodepart{five} + }; + }; + + \draw[pointer] (1.9, 3.1) -- ($(B)+(0,0.4)$) node[] {}; + \draw[pointer] (2.8, 3.1) -- ($(B)+(2.8,0.4)$) node[] {}; + \draw[pointer] (3.9, 3.1) -- ($(B)+(6,0.4)$) node[] {}; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/b-tree-3-evolution/Makefile b/tikz/b-tree-3-evolution/Makefile new file mode 100644 index 0000000..e4cc92e --- /dev/null +++ b/tikz/b-tree-3-evolution/Makefile @@ -0,0 +1,31 @@ +SOURCE = b-tree-3-evolution +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/b-tree-3-evolution/b-tree-3-evolution.tex b/tikz/b-tree-3-evolution/b-tree-3-evolution.tex new file mode 100644 index 0000000..aaa2043 --- /dev/null +++ b/tikz/b-tree-3-evolution/b-tree-3-evolution.tex @@ -0,0 +1,198 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{calc,shapes.multipart,chains,arrows,positioning} + +\tikzset{ + font=\tt, + >= stealth, + every picture/.style={thick}, + pointer/.style={*->}, + node/.style={ + align=center, + rectangle split, rectangle split horizontal, + rectangle split parts=#1, + draw, + anchor=center, + rectangle split part align={center}, + rectangle split empty part width=1.5, + rectangle split part fill = {white} + } +} + +\begin{document} +\begin{preview} +\begin{tabular}{c | c} +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (3,3){ + \tikz \node[node=1, rectangle split part fill={gray}] (A) { + \nodepart{one} + }; + }; +\end{tikzpicture} + +& + +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (3,3){ + \tikz \node[node=3, rectangle split part fill={gray, white, gray}] (A) { + \nodepart{one} + \nodepart{two}2 + \nodepart{three} + }; + }; +\end{tikzpicture} \\ + +\hline + +\\ + +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (3,3){ + \tikz \node[node=5, rectangle split part fill={gray, white, gray, white, gray}] (A) { + \nodepart{one} + \nodepart{two}2 + \nodepart{three} + \nodepart{four}4 + \nodepart{five} + }; + }; +\end{tikzpicture} + +& + +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (3,3){ + \tikz \node[node=7, rectangle split part fill={gray, white, gray, white, gray, white, gray}] (A) { + \nodepart{one} + \nodepart{two}2 + \nodepart{three} + \nodepart{four}4 + \nodepart{five} + \nodepart{six}6 + \nodepart{seven} + }; + }; +\end{tikzpicture} \\ + +\hline + +\\ + +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (3,3){ + \tikz \node[node=9, rectangle split part fill={gray, white, gray, white, gray, white, gray, white, gray}] (A) { + \nodepart{one} + \nodepart{two}2 + \nodepart{three} + \nodepart{four}4 + \nodepart{five} + \nodepart{six}6 + \nodepart{seven} + \nodepart{eight}8 + \nodepart{nine} + }; + }; +\end{tikzpicture} + +& + +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (3,3){ + \tikz \node[node=11, rectangle split part fill={gray, white, gray, white, gray, white, gray, white, gray, white, gray}] (A) { + \nodepart{one} + \nodepart{two}2 + \nodepart{three} + \nodepart{four}4 + \nodepart{five} + \nodepart{six}6 + \nodepart{seven} + \nodepart{eight}8 + \nodepart{nine} + \nodepart{ten}10 + \nodepart{eleven} + }; + }; +\end{tikzpicture} + +\\ + +\hline + +Node is full $\rightarrow$ first split node\\ + +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (2,3){ + \tikz \node[node=3, rectangle split part fill={gray, white, gray, white, gray, white, gray, white, gray, white, gray}] (A) { + \nodepart{one} + \nodepart{two}6 + \nodepart{three} + }; + }; + + \node[align=center, draw, fill=yellow] at (0,0){ + \tikz \node[node=5, rectangle split part fill={gray, white, gray, white, gray, white, gray, white, gray, white, gray}] (B) { + \nodepart{one} + \nodepart{two}2 + \nodepart{three} + \nodepart{four}4 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (3,0){ + \tikz \node[node=5, rectangle split part fill={gray, white, gray, white, gray, white, gray, white, gray, white, gray}] (C) { + \nodepart{one} + \nodepart{two}8 + \nodepart{three} + \nodepart{four}10 + \nodepart{five} + }; + }; + + \draw[pointer] (1.5, 3.1) -- ($(B)+(0,0.4)$) node[] {}; + \draw[pointer] (2.3, 3.1) -- ($(B)+(3,0.4)$) node[] {}; +\end{tikzpicture} + +& + +\begin{tikzpicture} + \node[align=center, draw, fill=yellow] at (2,3){ + \tikz \node[node=3, rectangle split part fill={gray, white, gray, white, gray, white, gray, white, gray, white, gray}] (A) { + \nodepart{one} + \nodepart{two}6 + \nodepart{three} + }; + }; + + \node[align=center, draw, fill=yellow] at (0,0){ + \tikz \node[node=5, rectangle split part fill={gray, white, gray, white, gray, white, gray, white, gray, white, gray}] (B) { + \nodepart{one} + \nodepart{two}2 + \nodepart{three} + \nodepart{four}4 + \nodepart{five} + }; + }; + + \node[align=center, draw, fill=yellow] at (3.5,0){ + \tikz \node[node=7, rectangle split part fill={gray, white, gray, white, gray, white, gray, white, gray, white, gray}] (C) { + \nodepart{one} + \nodepart{two}8 + \nodepart{three} + \nodepart{four}10 + \nodepart{five} + \nodepart{six}12 + \nodepart{seven} + }; + }; + + \draw[pointer] (1.5, 3.1) -- ($(B)+(0,0.4)$) node[] {}; + \draw[pointer] (2.3, 3.1) -- ($(B)+(3.5,0.4)$) node[] {}; +\end{tikzpicture} + +\end{tabular} +\end{preview} +\end{document} diff --git a/tikz/b-tree-node/Makefile b/tikz/b-tree-node/Makefile new file mode 100644 index 0000000..e41b90c --- /dev/null +++ b/tikz/b-tree-node/Makefile @@ -0,0 +1,31 @@ +SOURCE = b-tree-node +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/b-tree-node/b-tree-node.tex b/tikz/b-tree-node/b-tree-node.tex new file mode 100644 index 0000000..c9c91c8 --- /dev/null +++ b/tikz/b-tree-node/b-tree-node.tex @@ -0,0 +1,70 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{calc,shapes.multipart,chains,arrows,positioning} + +\tikzset{ + font=\tt, + >= stealth, + every picture/.style={thick}, + pointer/.style={*->}, + node/.style={ + align=center, + rectangle split, rectangle split horizontal, + rectangle split parts=#1, + draw, + anchor=center, + rectangle split part align={center}, + rectangle split empty part width=1.5, + rectangle split part fill = {orange!50, blue!50, white} + } +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + + \node[align=center, draw, fill=yellow]{ + \tikz \node[node=13] (A) { + \nodepart{one}\tiny False + \nodepart{two}5 + \nodepart{three} + \nodepart{four}-3 + \nodepart{five} + \nodepart{six}0 + \nodepart{seven} + \nodepart{eight}4 + \nodepart{nine} + \nodepart{ten}17 + \nodepart{eleven} + \nodepart{twelve}42 + \nodepart{thirteen} + }; + }; + + \node[orange!80] at ($(A.one)+(0, 0.6)$) {$\scriptscriptstyle isLeaf$}; + \node[blue!80] at ($(A.two)+(0, -0.5)$) {$\scriptscriptstyle n$}; + \node[gray] at ($(A.three)+(0, 0.6)$) {$\scriptscriptstyle c_1$}; + \node[gray] at ($(A.four)+(0, -0.5)$) {$\scriptscriptstyle key_1$}; + \node[gray] at ($(A.five)+(0, 0.6)$) {$\scriptscriptstyle c_2$}; + \node[gray] at ($(A.six)+(0, -0.5)$) {$\scriptscriptstyle key_2$}; + \node[gray] at ($(A.seven)+(0, 0.6)$) {$\scriptscriptstyle c_3$}; + \node[gray] at ($(A.eight)+(0, -0.5)$) {$\scriptscriptstyle key_3$}; + \node[gray] at ($(A.nine)+(0, 0.6)$) {$\scriptscriptstyle c_4$}; + \node[gray] at ($(A.ten)+(0, -0.5)$) {$\scriptscriptstyle key_4$}; + \node[gray] at ($(A.eleven)+(0, 0.6)$) {$\scriptscriptstyle c_5$}; + \node[gray] at ($(A.twelve)+(0, -0.5)$) {$\scriptscriptstyle key_5$}; + \node[gray] at ($(A.thirteen)+(0, 0.6)$) {$\scriptscriptstyle c_1$}; + + \draw[pointer] ($(A.three) + (0, 0.15)$) -- +(0,-1) node[] {}; + \draw[pointer] ($(A.five) + (0, 0.15)$) -- +(0,-1) node[] {}; + \draw[pointer] ($(A.seven) + (0, 0.15)$) -- +(0,-1) node[] {}; + \draw[pointer] ($(A.nine) + (0, 0.15)$) -- +(0,-1) node[] {}; + \draw[pointer] ($(A.eleven) + (0, 0.15)$) -- +(0,-1) node[] {}; + \draw[pointer] ($(A.thirteen) + (0, 0.15)$) -- +(0,-1) node[] {}; + +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/b-tree/Makefile b/tikz/b-tree/Makefile new file mode 100644 index 0000000..e1f4a20 --- /dev/null +++ b/tikz/b-tree/Makefile @@ -0,0 +1,31 @@ +SOURCE = b-tree-2 +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/b-tree/b-tree-2.tex b/tikz/b-tree/b-tree-2.tex new file mode 100644 index 0000000..01ffb46 --- /dev/null +++ b/tikz/b-tree/b-tree-2.tex @@ -0,0 +1,32 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{shapes.multipart, calc} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \tikzstyle{bplus}=[rectangle split, rectangle split horizontal,rectangle split ignore empty parts,draw, fill=white] + \tikzstyle{every node}=[bplus] + \tikzstyle{level 1}=[sibling distance=60mm] + \tikzstyle{level 2}=[sibling distance=15mm] + + \node {8 \nodepart{two} 14} [->] + child {node {2 \nodepart{two} 5} + child {node {0 \nodepart{two} 1}} + child {node {3 \nodepart{two} 4}} + child {node {6 \nodepart{two} 7}} + } + child {node {11} + child {node { 9 \nodepart{two} 10}} + child {node {12 \nodepart{two} 13}} + } + child {node {17} + child {node {15 \nodepart{two} 16}} + child {node {18 \nodepart{two} 19}} + }; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/b-tree/b-tree-3.tex b/tikz/b-tree/b-tree-3.tex new file mode 100644 index 0000000..afd2856 --- /dev/null +++ b/tikz/b-tree/b-tree-3.tex @@ -0,0 +1,29 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{shapes.multipart, calc} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \tikzstyle{bplus}=[rectangle split, rectangle split horizontal,rectangle split ignore empty parts,draw, fill=white] + \tikzstyle{every node}=[bplus] + \tikzstyle{level 1}=[sibling distance=60mm] + \tikzstyle{level 2}=[sibling distance=15mm] + + \node {11} [->] + child {node {3 \nodepart{two} 7} + child {node {0 \nodepart{two} 1 \nodepart{three} 2}} + child {node {4 \nodepart{two} 5 \nodepart{three} 6}} + child {node {8 \nodepart{two} 9 \nodepart{three} 10}} + } + child {node {15 \nodepart{two} 18} + child[sibling distance=20mm] {node {12 \nodepart{two} 13 \nodepart{three} 14}} + child {node {16 \nodepart{two} 17}} + child {node {19}} + }; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/bellman-ford-algorithm/Makefile b/tikz/bellman-ford-algorithm/Makefile new file mode 100644 index 0000000..19c46b0 --- /dev/null +++ b/tikz/bellman-ford-algorithm/Makefile @@ -0,0 +1,27 @@ +SOURCE = bellman-ford-algorithm + +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.toc *.snm *.out *.nav + +animatedGif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg + # Alternatively, only this one (produces worse results): + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg diff --git a/tikz/bellman-ford-algorithm/README b/tikz/bellman-ford-algorithm/README new file mode 100644 index 0000000..7b2a754 --- /dev/null +++ b/tikz/bellman-ford-algorithm/README @@ -0,0 +1 @@ +TODO: Not ready, make ready! diff --git a/tikz/bellman-ford-algorithm/bellman-ford-algorithm.tex b/tikz/bellman-ford-algorithm/bellman-ford-algorithm.tex new file mode 100644 index 0000000..e0931f1 --- /dev/null +++ b/tikz/bellman-ford-algorithm/bellman-ford-algorithm.tex @@ -0,0 +1,112 @@ +\documentclass{beamer} +\usepackage{tikz} +\usepackage{verbatim} +\usetikzlibrary{arrows,shapes} + +\begin{document} +\pgfdeclarelayer{background} +\pgfsetlayers{background,main} + +\tikzset{ + vertex/.style={ + circle, + fill=black!25, + minimum size=20pt, + inner sep=0pt, + text height=1ex, + text depth=1ex, + label={[weight label]center:\weight}, + label={[pred label]center:\pred} + }, + pred label/.style={ + font=\tiny, + xshift=0.3em, + yshift=-0.8ex, + text height=1ex, + text depth=0pt + }, + weight label/.style={ + font=\tiny, + xshift=-0.3em, + yshift=-0.8ex, + text height=1ex, + text depth=0pt + } +} + +\tikzstyle{vertexOnly}=[circle,fill=black!25,minimum size=20pt,inner sep=0pt] +\tikzstyle{selected vertex} = [vertex, fill=red!24] +\tikzstyle{edge} = [->,draw,thick] +\tikzstyle{weight} = [font=\small] +\tikzstyle{selected edge} = [draw,line width=5pt,-,red!50] +\tikzstyle{ignored edge} = [draw,line width=5pt,-,black!20] + +\begin{frame} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Given Graph % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{figure} +\begin{tikzpicture}[scale=2.5, auto,swap] + % First we draw the vertices + \foreach \pos/\name in {{(0,2)/a}, {(1,2)/b}, {(2,2)/c}, + {(0,1)/d}, {(1,1)/e}, {(2,1)/f}, + {(0,0)/g}, {(1,0)/h}, {(2,0)/i}} + \node[vertexOnly] (\name) at \pos {$\name$}; + % Connect vertices with edges and draw weights + \foreach \source/ \dest /\weight/\style in {a/b/0/, b/c/1/, a/d/2/, e/d/5/, + b/e/3/bend right, e/b/-1/bend right, b/f/4/above, f/i/3/, + i/e/1/, g/h/1/} + \path (\source) edge[->,\style, thick] node {$\weight$} (\dest); +\end{tikzpicture} +\end{figure} +\end{frame} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Initialisation % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} + \begin{figure} + \begin{tikzpicture}[scale=2.5, auto,swap] + % First we draw the vertices + \foreach \pos/\name/\weight/\pred in { + {(0,2)/a/$0$/-},{(1,2)/b/$\infty$/-}, {(2,2)/c/$\infty$/-}, + {(0,1)/d/$\infty$/-}, {(1,1)/e/$\infty$/-}, {(2,1)/f/$\infty$/-}, + {(0,0)/g/$\infty$/-}, {(1,0)/h/$\infty$/-}, {(2,0)/i/$\infty$/-}} + \node[vertex] (\name) at \pos {$\name$}; + + % Connect vertices with edges and draw weights + \foreach \source/ \dest /\weight/\style in { + a/b/0/, b/c/1/, a/d/2/, e/d/5/, b/e/3/bend right, + e/b/-1/bend right, b/f/4/above, f/i/3/, i/e/1/, + g/h/1/} + \path (\source) edge[->,\style, thick] node {$\weight$} (\dest); + \end{tikzpicture} + \end{figure} +\end{frame} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% first iteraton % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} + \begin{figure} + \begin{tikzpicture}[scale=2.5, auto,swap] + % First we draw the vertices + \foreach \pos/\name/\weight/\pred in { + {(1,2)/b/$\infty$/-}, {(2,2)/c/$\infty$/-}, + {(0,1)/d/$\infty$/-}, {(1,1)/e/$\infty$/-}, {(2,1)/f/$\infty$/-}, + {(0,0)/g/$\infty$/-}, {(1,0)/h/$\infty$/-}, {(2,0)/i/$\infty$/-}} + \node[vertex] (\name) at \pos {$\name$}; + + % Connect vertices with edges and draw weights + \foreach \source/ \dest /\weight/\style in { + a/b/0/, b/c/1/, a/d/2/, e/d/5/, b/e/3/bend right, + e/b/-1/bend right, b/f/4/above, f/i/3/, i/e/1/, + g/h/1/} + \path (\source) edge[->,\style, thick] node {$\weight$} (\dest); + \end{tikzpicture} + \end{figure} +\end{frame} + +\end{document} diff --git a/tikz/binary-search-tree/Makefile b/tikz/binary-search-tree/Makefile new file mode 100644 index 0000000..508c547 --- /dev/null +++ b/tikz/binary-search-tree/Makefile @@ -0,0 +1,31 @@ +SOURCE = binary-search-tree +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/binary-search-tree/binary-search-tree.tex b/tikz/binary-search-tree/binary-search-tree.tex new file mode 100644 index 0000000..ee86662 --- /dev/null +++ b/tikz/binary-search-tree/binary-search-tree.tex @@ -0,0 +1,59 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{arrows,positioning, calc} +\tikzstyle{vertex}=[draw,fill=black!15,circle,minimum size=18pt,inner sep=0pt] + + +\begin{document} +\begin{preview} +\begin{tikzpicture}[very thick,level/.style={sibling distance=70mm/#1}] +\node [vertex] (r){$17$} + child { + node [vertex] (a) {$9$} + child { + node [vertex] {$3$} + child { + node [vertex] {$-3$} + child {node [vertex] {$-4$}} + child { + node [vertex] {$2$} + child { + node [vertex] {$2$} + } + } + } + child { + node [vertex] {$8$} + child { + node [vertex] {$6$} + child { + node [vertex] {$5$} + } + child { + node [vertex] {$7$} + } + } + } + } + child { + node [vertex] {$11$} + child { + node [vertex] {$17$} + child { + node [vertex] {$17$} + } + } + } + } + child { + node [vertex] {$19$} + child { + node [vertex] {$20$} + } + }; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/binary-tree/Makefile b/tikz/binary-tree/Makefile new file mode 100644 index 0000000..b4e28d3 --- /dev/null +++ b/tikz/binary-tree/Makefile @@ -0,0 +1,31 @@ +SOURCE = binary-tree +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/binary-tree/binary-tree.tex b/tikz/binary-tree/binary-tree.tex new file mode 100644 index 0000000..247cb12 --- /dev/null +++ b/tikz/binary-tree/binary-tree.tex @@ -0,0 +1,45 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{arrows,positioning, calc} +\tikzstyle{vertex}=[draw,fill=black!15,circle,minimum size=20pt,inner sep=0pt] + + +\begin{document} +\begin{preview} +\begin{tikzpicture}[very thick,level/.style={sibling distance=60mm/#1}] +\node [vertex] (r){$17$} + child { + node [vertex] (a) {$19$} + child { + node [vertex] {$20$} + child { + node [vertex] {$-3$} + child {node [vertex] {$17$}} + child {node [vertex] {$5$}} + } + child {node [vertex] {$6$}} + } + child { + node [vertex] {$3$} + child {node [vertex] {$7$}} + child {node [vertex] {$2$}} + } + } + child { + node [vertex] {$9$} + child { + node [vertex] {$8$} + child {node [vertex] {$2$}} + } + child { + node [vertex] {$11$} + child {node [vertex] {$17$}} + child {node [vertex] {$-4$}} + } + }; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/birthday-paradox/Makefile b/tikz/birthday-paradox/Makefile new file mode 100644 index 0000000..85698d2 --- /dev/null +++ b/tikz/birthday-paradox/Makefile @@ -0,0 +1,31 @@ +SOURCE = birthday-paradox +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/birthday-paradox/birthday-paradox.tex b/tikz/birthday-paradox/birthday-paradox.tex new file mode 100644 index 0000000..b2a60f2 --- /dev/null +++ b/tikz/birthday-paradox/birthday-paradox.tex @@ -0,0 +1,49 @@ +% Plot of the probability that two people out of n people have the +% same birthday. +% Author: Martin Thoma +% Source: http://martin-thoma.com/plotting-graphs-with-pgfplots/ + +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{pgfplots} +\usepackage{tikz} +\usetikzlibrary{arrows, positioning, calc} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \begin{axis}[ + width=15cm, height=8cm, % size of the image + grid = major, + grid style={dashed, gray!30}, + %xmode=log,log basis x=10, + %ymode=log,log basis y=10, + xmin=0, % start the diagram at this x-coordinate + xmax=62, % end the diagram at this x-coordinate + ymin=0, % start the diagram at this y-coordinate + ymax=1.1, % end the diagram at this y-coordinate + /pgfplots/xtick={0,5,...,60}, % make steps of length 5 + extra x ticks={23}, + extra y ticks={0.507297}, + axis background/.style={fill=white}, + ylabel=probability of at least one birthday-collision, + xlabel=people, + tick align=outside] + + % import the correct data from a CSV file + \addplot table [id=exp]{data.csv}; + + % mark x=23 + \coordinate (a) at (axis cs:23,0.507297); + \draw[blue, dashed, thick](a -| current plot begin) -- (a); + \draw[blue, dashed, thick](a |- current plot begin) -- (a); + + % plot the stirling-formulae + \addplot[domain=0:60, red, thick] + {1-(365/(365-x))^(365.5-x)*e^(-x)}; + \end{axis} +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/birthday-paradox/calculate.py b/tikz/birthday-paradox/calculate.py new file mode 100644 index 0000000..f4588c7 --- /dev/null +++ b/tikz/birthday-paradox/calculate.py @@ -0,0 +1,14 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from math import factorial +from gmpy import bincoef + +f = open('data.csv', 'w') +f.write('People\tprobability\n') + +def prob(people): + return 1.0 - float(factorial(people)*bincoef(365,people))/(365**people) + +for people in xrange(60+1): + f.write("%i\t%f\n" % (people, prob(people))) diff --git a/tikz/birthday-paradox/data.csv b/tikz/birthday-paradox/data.csv new file mode 100644 index 0000000..6f01917 --- /dev/null +++ b/tikz/birthday-paradox/data.csv @@ -0,0 +1,62 @@ +People probability +0 0.000000 +1 0.000000 +2 0.002740 +3 0.008204 +4 0.016356 +5 0.027136 +6 0.040462 +7 0.056236 +8 0.074335 +9 0.094624 +10 0.116948 +11 0.141141 +12 0.167025 +13 0.194410 +14 0.223103 +15 0.252901 +16 0.283604 +17 0.315008 +18 0.346911 +19 0.379119 +20 0.411438 +21 0.443688 +22 0.475695 +23 0.507297 +24 0.538344 +25 0.568700 +26 0.598241 +27 0.626859 +28 0.654461 +29 0.680969 +30 0.706316 +31 0.730455 +32 0.753348 +33 0.774972 +34 0.795317 +35 0.814383 +36 0.832182 +37 0.848734 +38 0.864068 +39 0.878220 +40 0.891232 +41 0.903152 +42 0.914030 +43 0.923923 +44 0.932885 +45 0.940976 +46 0.948253 +47 0.954774 +48 0.960598 +49 0.965780 +50 0.970374 +51 0.974432 +52 0.978005 +53 0.981138 +54 0.983877 +55 0.986262 +56 0.988332 +57 0.990122 +58 0.991665 +59 0.992989 +60 0.994123 diff --git a/tikz/circular-cone/Makefile b/tikz/circular-cone/Makefile new file mode 100644 index 0000000..10215d0 --- /dev/null +++ b/tikz/circular-cone/Makefile @@ -0,0 +1,25 @@ +SOURCE = circular-cone +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/circular-cone/circular-cone.tex b/tikz/circular-cone/circular-cone.tex new file mode 100644 index 0000000..fe23d9c --- /dev/null +++ b/tikz/circular-cone/circular-cone.tex @@ -0,0 +1,31 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usepackage{tikz-3dplot} +\usetikzlibrary{shapes, calc} +\begin{document} +\begin{preview} +\tdplotsetmaincoords{70}{0} +\begin{tikzpicture}[tdplot_main_coords] + \def\RI{2} + \def\RII{1.25} + + \draw[thick] (\RI,0) + \foreach \x in {0,300,240,180} { -- (\x:\RI) node at (\x:\RI) (R1-\x) {} }; + \draw[dashed,thick] (R1-0.center) + \foreach \x in {60,120,180} { -- (\x:\RI) node at (\x:\RI) (R1-\x) {} }; + \path[fill=gray!30] (\RI,0) + \foreach \x in {0,60,120,180,240,300} { -- (\x:\RI)}; + + \begin{scope}[yshift=2cm] + \draw[thick,fill=gray!30,opacity=0.2] (\RII,0) + \foreach \x in {0,60,120,180,240,300,360} + { -- (\x:\RII) node at (\x:\RII) (R2-\x) {}}; + \end{scope} + + \foreach \x in {0,180,240,300} { \draw (R1-\x.center)--(R2-\x.center); }; + \foreach \x in {60,120} { \draw[dashed] (R1-\x.center)--(R2-\x.center); }; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/cyclic-graph/Makefile b/tikz/cyclic-graph/Makefile new file mode 100644 index 0000000..fcfaa70 --- /dev/null +++ b/tikz/cyclic-graph/Makefile @@ -0,0 +1,31 @@ +SOURCE = cyclic-graph +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/cyclic-graph/cyclic-graph.tex b/tikz/cyclic-graph/cyclic-graph.tex new file mode 100644 index 0000000..a61f12a --- /dev/null +++ b/tikz/cyclic-graph/cyclic-graph.tex @@ -0,0 +1,36 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{arrows,positioning, calc} +\tikzstyle{vertex}=[draw,fill=black!15,circle,minimum size=20pt,inner sep=0pt] +\tikzstyle{selected edge} = [draw,line width=5pt,-,red!50] + +\begin{document} +\pgfdeclarelayer{background} +\pgfsetlayers{background,main} + +\begin{preview} +\begin{tikzpicture} [scale=1.2] + \node (a)[vertex] at (0,2) {a}; + \node (b)[vertex] at (1,1) {b}; + \node (c)[vertex] at (3,2) {c}; + \node (d)[vertex] at (4,1) {d}; + \node (e)[vertex] at (2,0) {e}; + \node (f)[vertex] at (1,3) {f}; + \node (g)[vertex] at (5,3) {g}; + \node (h)[vertex] at (0,1) {h}; + + \foreach \from/\to in {a/f,f/g,h/b,b/c,c/d,d/e,e/b,f/c} + \draw (\from) -- (\to); + + \begin{pgfonlayer}{background} + \draw (b.center) edge[selected edge] (c.center); + \draw (c.center) edge[selected edge] (d.center); + \draw (d.center) edge[selected edge] (e.center); + \draw (e.center) edge[selected edge] (b.center); + \end{pgfonlayer} +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/dijkstra-fail/Makefile b/tikz/dijkstra-fail/Makefile new file mode 100644 index 0000000..14d60bf --- /dev/null +++ b/tikz/dijkstra-fail/Makefile @@ -0,0 +1,25 @@ +SOURCE = dijkstra-fail +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/dijkstra-fail/dijkstra-fail.tex b/tikz/dijkstra-fail/dijkstra-fail.tex new file mode 100644 index 0000000..09c22b8 --- /dev/null +++ b/tikz/dijkstra-fail/dijkstra-fail.tex @@ -0,0 +1,34 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{arrows,positioning, calc} +\tikzset{ + %Define standard arrow tip + ->,>=stealth',shorten >=1pt,auto,node distance=3cm, very thick, + % Define arrow style + main node/.style={ + circle, + fill=blue!20, + draw, + font=\sffamily\Large\bfseries + } +} + +\begin{document} +\begin{preview} +\begin{tikzpicture}[,] + + \node[main node] (A) {A}; + \node[main node] (C) [below of=A] {C}; + \node[main node] (B) [right of=A] {B}; + \node[main node] (D) [right of=C] {D}; + + \path[every node/.style={font=\sffamily\small}] + (A) edge node {4} (C) + edge node {3} (B) + (C) edge node {-2} (B) + (B) edge node {1} (D); +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/dijkstra/Makefile b/tikz/dijkstra/Makefile new file mode 100644 index 0000000..72c5140 --- /dev/null +++ b/tikz/dijkstra/Makefile @@ -0,0 +1,25 @@ +SOURCE = dot-product-1 +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/dijkstra/README b/tikz/dijkstra/README new file mode 100644 index 0000000..b98e71a --- /dev/null +++ b/tikz/dijkstra/README @@ -0,0 +1,2 @@ +Das ist nicht fertig! +TODO: Fertig stellen diff --git a/tikz/dijkstra/dijkstra.py b/tikz/dijkstra/dijkstra.py new file mode 100644 index 0000000..962cf63 --- /dev/null +++ b/tikz/dijkstra/dijkstra.py @@ -0,0 +1,93 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +class Node(object): + """ A node. """ + + def __init__(self, x, y, data): + self._data = data # data connected to the node + self._x = x # x-position + self._y = y # y-position + + data = property(fget=lambda self: self._data) + x = property(fget=lambda self: self._x) + y = property(fget=lambda self: self._y) + + def __str__(self): + return "{(%i,%i)/%s}" % (self.x, self.y, str(self.data)) + + def __repr__(self): + return "{(%i,%i)/%s}" % (self.x, self.y, str(self.data)) + +class Edge(object): + """ An edge. """ + + def __init__(self, startNode, endNode, weight=0, directed=False): + self._startNode = startNode + self._endNode = endNode + self._weight = weight + self._directed = directed + + startNode = property(fget=lambda self: self._startNode) + endNode = property(fget=lambda self: self._endNode) + weight = property(fget=lambda self: self._weight) + directed = property(fget=lambda self: self._directed) + + def __str__(self): + return "%s/%s/%i" % (str(id(self.startNode)), str(id(self.endNode)), self.weight) + + def __repr__(self): + return "%s/%s/%i" % (str(id(self.startNode)), str(id(self.endNode)), self.weight) + +class Graph(object): + """ A graph. """ + + def __init__(self, directed=False): + self._directed = directed + self._edges = [] + self._vertices = [] + + directed = property(fget=lambda self: self._directed) + edges = property(fget=lambda self: self._edges) + vertices = property(fget=lambda self: self._vertices) + + def printVertices(self): + vertexString = "" + for vertex in self.vertices: + vertexString += str(vertex) + return vertexString + + def printEdges(self): + edgeString = "% Connect vertices with edges and draw weights\n" + edgeString += "\\foreach \source/ \dest /\weight in {" + for i, edge in enumerate(self.edges): + if i != 0: + edgeString += ", " + edgeString += str(edge) + edgeString += "}\n" + edgeString += "\path[edge] (\source) -- node[weight] {$\weight$} (\dest);" + return edgeString + + def printGraph(self): + print("\\begin{tikzpicture}[scale=1.8, auto,swap]") + print("\\foreach \pos/\\name in {" + self.printVertices() + "}") + print("\t\\node[vertex] (\\name) at \pos {$\\name$};") + print(self.printEdges()) + print("\end{tikzpicture}") + +if '__main__' == __name__: + graph = Graph() + k1 = Node(1,2, 1) + k2 = Node(3,0, 2) + k3 = Node(3,3, 3) + k6 = Node(1,4, 6) + k5 = Node(4,5, 5) + k4 = Node(5,3, 4) + graph._vertices.append(k1) + graph._vertices.append(k2) + graph._vertices.append(k3) + graph._vertices.append(k4) + graph._vertices.append(k5) + graph._vertices.append(k6) + graph._edges.append(Edge(k1,k2, 7)) + graph.printGraph() diff --git a/tikz/dijkstra/dot-product-1.tex b/tikz/dijkstra/dot-product-1.tex new file mode 100644 index 0000000..abf8c0e --- /dev/null +++ b/tikz/dijkstra/dot-product-1.tex @@ -0,0 +1,24 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{arrows,positioning} +\tikzset{ + %Define standard arrow tip + >=stealth', + % Define arrow style + pil/.style={ + ->, + thick} +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \draw[fill=green!30] (0,0) -- (90:.75cm) arc (90:27:.75cm); + \draw[pil,color=black] (0,0) -- node[right=2pt] {$\vec a$} (27:2.2cm); + \draw[pil,color=black] (0,0) -- node[near end, right=-3pt] {$\vec b$} (90:2cm); + \draw(60:0.5cm) node {$\varphi$}; + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/dot-product-1/Makefile b/tikz/dot-product-1/Makefile new file mode 100644 index 0000000..72c5140 --- /dev/null +++ b/tikz/dot-product-1/Makefile @@ -0,0 +1,25 @@ +SOURCE = dot-product-1 +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/dot-product-1/dot-product-1.tex b/tikz/dot-product-1/dot-product-1.tex new file mode 100644 index 0000000..abf8c0e --- /dev/null +++ b/tikz/dot-product-1/dot-product-1.tex @@ -0,0 +1,24 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{arrows,positioning} +\tikzset{ + %Define standard arrow tip + >=stealth', + % Define arrow style + pil/.style={ + ->, + thick} +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \draw[fill=green!30] (0,0) -- (90:.75cm) arc (90:27:.75cm); + \draw[pil,color=black] (0,0) -- node[right=2pt] {$\vec a$} (27:2.2cm); + \draw[pil,color=black] (0,0) -- node[near end, right=-3pt] {$\vec b$} (90:2cm); + \draw(60:0.5cm) node {$\varphi$}; + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/dot-product-2/Makefile b/tikz/dot-product-2/Makefile new file mode 100644 index 0000000..63a7c5d --- /dev/null +++ b/tikz/dot-product-2/Makefile @@ -0,0 +1,25 @@ +SOURCE = dot-product-2 +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/dot-product-2/dot-product-2.tex b/tikz/dot-product-2/dot-product-2.tex new file mode 100644 index 0000000..5e71bd6 --- /dev/null +++ b/tikz/dot-product-2/dot-product-2.tex @@ -0,0 +1,30 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{arrows,positioning} +\tikzset{ + %Define standard arrow tip + >=stealth', + % Define arrow style + pil/.style={ + ->, + thick} +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \draw[fill=gray!30] (27:0.90) -- node[right=-0.28cm, near end] {$\cdot$} (27:1.08) + arc (27:117:.18cm); + \draw[fill=green!30] (0,0) -- (90:.55cm) arc (90:27:.55cm); + \draw[pil,color=red] (0,0) -- node[right=2pt] {$\vec a$} (27:3cm); + \draw[pil,color=blue] (0,0) -- node[near end, right=-3pt] {$\vec b$} (90:2cm); + + \draw[pil,color=violet] (0,0) -- node[near start, right=7pt] {$\vec b_{\vec a}$} (27:0.90cm); + \draw[color=gray, dashed] (27:0.90) -- node[near end, right] {} (90:2cm); + + \draw(60:0.35cm) node {$\varphi$}; + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/dot-product-3/Makefile b/tikz/dot-product-3/Makefile new file mode 100644 index 0000000..73ef24f --- /dev/null +++ b/tikz/dot-product-3/Makefile @@ -0,0 +1,25 @@ +SOURCE = dot-product-3.3 +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/dot-product-3/dot-product-3.1.tex b/tikz/dot-product-3/dot-product-3.1.tex new file mode 100644 index 0000000..a560531 --- /dev/null +++ b/tikz/dot-product-3/dot-product-3.1.tex @@ -0,0 +1,23 @@ +\documentclass{article} +\usepackage{gensymb} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{arrows,positioning,decorations.pathreplacing,shapes} +\tikzset{ + %Define standard arrow tip + >=stealth', + % Define arrow style + pil/.style={ + ->, + thick} +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \draw[pil] (0,0) -- node[near end, above] {$\vec a$} (3cm, 0cm); + \draw[pil] (0,0.5cm) -- node[near end, above] {$\vec b$} (2cm,0.5cm); + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/dot-product-3/dot-product-3.2.tex b/tikz/dot-product-3/dot-product-3.2.tex new file mode 100644 index 0000000..027d2ae --- /dev/null +++ b/tikz/dot-product-3/dot-product-3.2.tex @@ -0,0 +1,25 @@ +\documentclass{article} +\usepackage{gensymb} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{arrows,positioning,decorations.pathreplacing,shapes} +\tikzset{ + %Define standard arrow tip + >=stealth', + % Define arrow style + pil/.style={ + ->, + thick} +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \draw[fill=gray!30, label=$a$] (0,0) -- node[above, near start] {$\cdot$} (0.5,0) + arc (0:90:0.5cm); + \draw[pil] (0,0) -- node[near end, above] {$\vec a$} (3cm, 0); + \draw[pil] (0,0) -- node[near end, right] {$\vec b$} (90:2cm); + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/dot-product-3/dot-product-3.3.tex b/tikz/dot-product-3/dot-product-3.3.tex new file mode 100644 index 0000000..e1dff1a --- /dev/null +++ b/tikz/dot-product-3/dot-product-3.3.tex @@ -0,0 +1,25 @@ +\documentclass{article} +\usepackage{gensymb} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{arrows,positioning,decorations.pathreplacing,shapes} +\tikzset{ + %Define standard arrow tip + >=stealth', + % Define arrow style + pil/.style={ + ->, + thick} +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \draw[fill=green!30, label=$a$] (0,0) -- node[above] {$\varphi$} (0.7,0) + arc (0:60:0.7cm); + \draw[pil] (0,0) -- node[near end, above] {$\vec a$} (3cm, 0); + \draw[pil] (0,0) -- node[near end, right] {$\vec b$} (60:2cm); + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/dot-product-4/Makefile b/tikz/dot-product-4/Makefile new file mode 100644 index 0000000..d2eefa8 --- /dev/null +++ b/tikz/dot-product-4/Makefile @@ -0,0 +1,25 @@ +SOURCE = dot-product-4 +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/dot-product-4/dot-product-4.tex b/tikz/dot-product-4/dot-product-4.tex new file mode 100644 index 0000000..78871e5 --- /dev/null +++ b/tikz/dot-product-4/dot-product-4.tex @@ -0,0 +1,34 @@ +\documentclass{article} +\usepackage{gensymb} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{arrows,positioning, calc} +\tikzset{ + %Define standard arrow tip + >=stealth', + % Define arrow style + pil/.style={ + ->, + thick} +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \draw[fill=green!30, dotted] (0,0) -- (90:1.00cm) arc (90:25:1.00cm); + \draw[fill=green!30, dotted] (6.8,3) -- (6.8,2) arc (-90:-155:1.00cm); + \draw(6.5,2.5) node {$\scriptstyle \varphi$}; + \draw(50:0.6cm) node {$\scriptscriptstyle \varphi = 63 \degree$}; + \coordinate[label=left:$\vec F$] (F) at (0cm, 3cm); + \coordinate[label=120:$A$,color=red] (A) at (0cm, 0cm); + \coordinate[label=right:$B$,color=red] (B) at (6.8cm, 3cm); + \draw[->, very thick, color=red] (A) to[] node[above, rotate=27] {$\vec s$} (B); + \draw[pil] (0,0) -- node[near end, right] {$F = 5 \mathrm{N}$} (0, 3cm); + \draw[color=gray, dashed] (0cm,0) -- node {} (6.8cm, 0cm); + \draw[color=gray, dashed] (6.8cm,0) -- node {} (6.8cm, 3cm); + \node (s) at ($(A)!0.5!(B)$) [below,rotate=25] {$s = 3\mathrm{m}$}; + \node (txt) at ($(6.8,0)!0.4!(B)$) [below,rotate=90] {$\scriptscriptstyle h = s \cdot \cos(\varphi)$}; + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/dot-product-5/Makefile b/tikz/dot-product-5/Makefile new file mode 100644 index 0000000..4500115 --- /dev/null +++ b/tikz/dot-product-5/Makefile @@ -0,0 +1,25 @@ +SOURCE = dot-product-5 +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/dot-product-5/dot-product-5.tex b/tikz/dot-product-5/dot-product-5.tex new file mode 100644 index 0000000..a204947 --- /dev/null +++ b/tikz/dot-product-5/dot-product-5.tex @@ -0,0 +1,40 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{arrows,positioning, calc} +\tikzset{ + %Define standard arrow tip + >=stealth', + % Define arrow style + pil/.style={ + ->, + thick} +} + +\begin{document} +\begin{preview} +\begin{tikzpicture}[scale=0.8] + % draw the background + \draw [line width=0.1pt, fill=gray!2] (0,0) -- (3, 3) -- (5,0) -- cycle; + + % angle gamma + \begin{scope}[shift={(3, 3)}] + \draw[fill=green!30] (0,0) -- (-135:.75cm) arc (-135:-55:.75cm); + \draw (-90:0.5cm) node {$\gamma$}; + \end{scope} + + \coordinate[label=left:$A$] (A) at (0,0); + \coordinate[label=right:$B$] (B) at (5,0); + \coordinate[label=above:$C$] (C) at (3,3); + \ + \draw[->, very thick] (A) to[] node[above] {$\vec c$} (B); + \draw[->, very thick] (C) to[] node[above] {$\vec b$} (A); + \draw[->, very thick] (C) to[] node[above=0.1cm] {$\vec a$} (B); + + \coordinate[label=-90:$c$] (c) at ($(A)!0.5!(B)$); + \coordinate[label=-120:$a$] (a) at ($(B)!0.5!(C)$); + \coordinate[label=-45:$b$] (b) at ($(C)!0.5!(A)$); + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/dot-product-6/Makefile b/tikz/dot-product-6/Makefile new file mode 100644 index 0000000..0e4bb08 --- /dev/null +++ b/tikz/dot-product-6/Makefile @@ -0,0 +1,25 @@ +SOURCE = dot-product-6 +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/dot-product-6/dot-product-6.tex b/tikz/dot-product-6/dot-product-6.tex new file mode 100644 index 0000000..77b5783 --- /dev/null +++ b/tikz/dot-product-6/dot-product-6.tex @@ -0,0 +1,24 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{arrows,positioning} +\tikzset{ + %Define standard arrow tip + >=stealth', + % Define arrow style + pil/.style={ + ->, + thick} +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \draw[fill=gray!30, label=$a$] (0,0) -- node[above, near start] {$\cdot$} (0.5,0) + arc (0:90:0.5cm); + \draw[pil] (0,0) -- node[near end, above] {$\vec e_1$} (2cm, 0); + \draw[pil] (0,0) -- node[near end, right] {$\vec e_2$} (0, 2cm); + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/doubly-linked-list/Makefile b/tikz/doubly-linked-list/Makefile new file mode 100644 index 0000000..799fa9b --- /dev/null +++ b/tikz/doubly-linked-list/Makefile @@ -0,0 +1,31 @@ +SOURCE = doubly-linked-list +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/doubly-linked-list/doubly-linked-list.tex b/tikz/doubly-linked-list/doubly-linked-list.tex new file mode 100644 index 0000000..7754119 --- /dev/null +++ b/tikz/doubly-linked-list/doubly-linked-list.tex @@ -0,0 +1,51 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{calc,shapes.multipart,chains,arrows,positioning} + +\tikzset{ + squarecross/.style={ + draw, rectangle,minimum size=18pt, fill=orange!80, + inner sep=0pt, text=black, + path picture = { + \draw[black] + (path picture bounding box.north west) -- + (path picture bounding box.south east) + (path picture bounding box.south west) -- + (path picture bounding box.north east); + } + } +} + +\begin{document} +\begin{preview} +\begin{tikzpicture}[ + list/.style={ + very thick, rectangle split, + rectangle split parts=3, draw, + rectangle split horizontal, minimum size=18pt, + inner sep=5pt, text=black, + rectangle split part fill={blue!20, red!20, blue!20} + }, + ->, start chain, very thick + ] + + \node[list,on chain] (A) {\nodepart{second} 12}; + \node[list,on chain] (B) {\nodepart{second} 99}; + \node[list,on chain] (C) {\nodepart{second} 37}; + + \node[squarecross] (D) [right=of C] {}; + \node[squarecross] (E) [left= of A] {}; + + \path[*->] let \p1 = (A.three), \p2 = (A.center) in (\x1,\y2) edge [bend left] ($(B.one)+(0,0.2)$); + \path[*->] let \p1 = (B.three), \p2 = (B.center) in (\x1,\y2) edge [bend left] ($(C.one)+(0,0.2)$); + \draw[*->] let \p1 = (C.three), \p2 = (C.center) in (\x1,\y2) -- (D); + + \draw[*->] ($(A.one)+(0.2,0.1)$) -- (E); + \path[*->] ($(B.one)+(0.1,0.1)$) edge [bend left] ($(A.three)+(0,-0.05)$); + \path[*->] ($(C.one)+(0.1,0.1)$) edge [bend left] ($(B.three)+(0,-0.05)$); +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/equilateral-triangle-heights/Makefile b/tikz/equilateral-triangle-heights/Makefile new file mode 100644 index 0000000..b10fbd9 --- /dev/null +++ b/tikz/equilateral-triangle-heights/Makefile @@ -0,0 +1,25 @@ +SOURCE = equilateral-triangle-heights +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/equilateral-triangle-heights/equilateral-triangle-heights.tex b/tikz/equilateral-triangle-heights/equilateral-triangle-heights.tex new file mode 100644 index 0000000..26f187f --- /dev/null +++ b/tikz/equilateral-triangle-heights/equilateral-triangle-heights.tex @@ -0,0 +1,73 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{arrows,positioning, calc} +\tikzset{ + %Define standard arrow tip + >=stealth', + % Define arrow style + pil/.style={ + ->, + thick} +} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + + % draw the background + \draw [line width=1.5pt, fill=gray!2] (0,0) -- (60:4) -- (4,0) -- cycle; + + \coordinate[label=left:$A$] (A) at (0,0); + \coordinate[label=right:$B$] (B) at (4,0); + \coordinate[label=above:$C$] (C) at (2,3.464); + + \coordinate[label=below:$c$](c) at ($ (A)!.5!(B) $); + \coordinate[label=left:$b$](b) at ($ (A)!.5!(C) $); + \coordinate[label=right:$a$](a) at ($ (B)!.5!(C) $); + + % angle alpha + \draw[fill=green!30] (0,0) -- (0:0.75cm) arc (0:60:.75cm); + \draw (0.35cm,0.25cm) node {$\alpha$}; + + % angle beta + \begin{scope}[shift={(4cm,0cm)}] + \draw[fill=green!30] (0,0) -- (-180:0.75cm) arc (180:120:0.75cm); + \draw[color=gray, dashed] (0,0) -- node[sloped, above=-0.1cm] {$\scriptstyle h_b$} (150:3.464cm); + \draw (150:0.5cm) node {$\beta$}; + \end{scope} + + % angle gamma + \begin{scope}[shift={(60:4)}] + \draw[fill=green!30] (0,0) -- (-120:.75cm) arc (-120:-60:.75cm); + \draw[color=gray, dashed] (0,0) -- node[right=-0.1cm] {$\scriptstyle h_c$} (-90:3.464cm); + \draw (-90:0.5cm) node {$\gamma$}; + \end{scope} + + % Sign for right angle of h_c + \begin{scope}[shift={(2,0)}] + \draw[fill=gray!30] (0,0) -- node[above=-0.15cm,near start] {$\cdot$} (0:0.18cm) + arc (0:90:.18cm); + \end{scope} + + % sign of right angle of h_a + \begin{scope}[shift={(30:3.464cm)}] + \draw[fill=gray!30] (0,0) -- node[near end,right=-0.28cm] {$\cdot$} (-60:0.18cm) + arc (-60:-150:.18cm); + \end{scope} + + % sign of right angle of h_b + \begin{scope}[shift={(60:2cm)}] + \draw[fill=gray!30] (0,0) -- node[right=-0.08cm, near start] {$\cdot$} (60:0.18cm) + arc (60:-30:.18cm); + \end{scope} + + % Height with label + \draw[color=gray, dashed] (0,0) -- node[sloped, above=-0.1cm] {$\scriptstyle h_a$} (30:3.464cm); + + % The triangle + \draw [line width=1.5pt] (0,0) -- (60:4) -- (4,0) -- cycle; + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/equilateral-triangle/Makefile b/tikz/equilateral-triangle/Makefile new file mode 100644 index 0000000..0c119ae --- /dev/null +++ b/tikz/equilateral-triangle/Makefile @@ -0,0 +1,25 @@ +SOURCE = equilateral-triangle +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/equilateral-triangle/equilateral-triangle.tex b/tikz/equilateral-triangle/equilateral-triangle.tex new file mode 100644 index 0000000..e3512f8 --- /dev/null +++ b/tikz/equilateral-triangle/equilateral-triangle.tex @@ -0,0 +1,42 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{positioning, calc} + +\begin{document} +\begin{preview} +\begin{tikzpicture}[scale=0.8] + + % draw the background + \draw [line width=1.5pt, fill=gray!2] (0,0) -- (60:4) -- (4,0) -- cycle; + + \coordinate[label=left:$A$] (A) at (0,0); + \coordinate[label=right:$B$] (B) at (4,0); + \coordinate[label=above:$C$] (C) at (2,3.464); + + \coordinate[label=below:$c$](c) at ($ (A)!.5!(B) $); + \coordinate[label=left:$b$] (b) at ($ (A)!.5!(C) $); + \coordinate[label=right:$a$](a) at ($ (B)!.5!(C) $); + + % angle alpha + \draw[fill=green!30] (0,0) -- (0:0.75cm) arc (0:60:.75cm); + \draw (0.35cm,0.25cm) node {$\alpha$}; + + % angle beta + \begin{scope}[shift={(4cm,0cm)}] + \draw[fill=green!30] (0,0) -- (-180:0.75cm) arc (180:120:0.75cm); + \draw (150:0.5cm) node {$\beta$}; + \end{scope} + + % angle gamma + \begin{scope}[shift={(60:4)}] + \draw[fill=green!30] (0,0) -- (-120:.75cm) arc (-120:-60:.75cm); + \draw (-90:0.5cm) node {$\gamma$}; + \end{scope} + + % the triangle + \draw [line width=1.5pt] (A) -- (B) -- (C) -- cycle; + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/evaluation-tree/Makefile b/tikz/evaluation-tree/Makefile new file mode 100644 index 0000000..8d13bcd --- /dev/null +++ b/tikz/evaluation-tree/Makefile @@ -0,0 +1,25 @@ +SOURCE = evaluation-tree +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/evaluation-tree/evaluation-tree.tex b/tikz/evaluation-tree/evaluation-tree.tex new file mode 100644 index 0000000..3086ad0 --- /dev/null +++ b/tikz/evaluation-tree/evaluation-tree.tex @@ -0,0 +1,26 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{shapes, calc} +\tikzstyle{vertex}=[draw,fill=black!15,circle,minimum size=20pt,inner sep=0pt] + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \node[vertex] {+} + child { + node[vertex] {+} + child { + node[vertex] {+} + child { node[vertex] {i} } + child { node[vertex] {++i} } + } + child { node[vertex] {i++} } + } child { + node[vertex] {++i} + } + ; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/heap/Makefile b/tikz/heap/Makefile new file mode 100644 index 0000000..1b7cfee --- /dev/null +++ b/tikz/heap/Makefile @@ -0,0 +1,31 @@ +SOURCE = heap +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/heap/heap.tex b/tikz/heap/heap.tex new file mode 100644 index 0000000..fa5c934 --- /dev/null +++ b/tikz/heap/heap.tex @@ -0,0 +1,47 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{arrows,positioning, calc} +\tikzstyle{vertex}=[draw,fill=black!15,circle,minimum size=18pt,inner sep=0pt] + + +\begin{document} +\begin{preview} +\begin{tikzpicture}[very thick,level/.style={sibling distance=70mm/#1}] +\node [vertex] (r){$-4$} + child { + node [vertex] (a) {$2$} + child { + node [vertex] {$5$} + child { + node [vertex] {$6$} + child {node [vertex] {$20$}} + } + child { + node [vertex] {$9$} + } + } + child { + node [vertex] {$3$} + child {node [vertex] {$19$}} + child {node [vertex] {$7$}} + } + } + child { + node [vertex] {$-3$} + child { + node [vertex] {$8$} + child {node [vertex] {$17$}} + child {node [vertex] {$17$}} + } + child { + node [vertex] {$2$} + child {node [vertex] {$11$}} + child {node [vertex] {$17$}} + } + }; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/isosceles-triangle-more/Makefile b/tikz/isosceles-triangle-more/Makefile new file mode 100644 index 0000000..f2f188b --- /dev/null +++ b/tikz/isosceles-triangle-more/Makefile @@ -0,0 +1,25 @@ +SOURCE = isosceles-triangle-more +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/isosceles-triangle-more/isosceles-triangle-more.tex b/tikz/isosceles-triangle-more/isosceles-triangle-more.tex new file mode 100644 index 0000000..f1e3f92 --- /dev/null +++ b/tikz/isosceles-triangle-more/isosceles-triangle-more.tex @@ -0,0 +1,107 @@ +\documentclass{article} + +\usepackage{xcolor} +\definecolor{cWinkelhalbierende}{HTML}{00940A} +\definecolor{cSeitenhalbierende}{HTML}{FF0000} +\definecolor{cAchse}{HTML} {94008A} +\definecolor{cMittelsenkrechten}{HTML}{181FED} + +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{shapes, calc} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \coordinate[label=left:$A$] (A) at (0,0); + \coordinate[label=right:$B$] (B) at (3.2,0); + \coordinate[label=left:$C$] (C) at (1.6,4); + + % Draw the background of the triangle + \node[isosceles triangle, isosceles triangle apex angle=44,draw, + inner sep=0pt,anchor=lower side,rotate=90,draw=black, + line width=1.5pt, minimum height=4cm, fill=gray!2] + (triangle) at (1.6,-0.05) {}; + + % Rechte Winkel + \begin{scope}[shift={($(A)!0.5!(C)$)}, rotate=-22] + \draw[fill=gray!30] (0,0) -- (-180:0.25cm) arc (180:90:0.25cm); + \draw (140:0.15cm) node {$\cdot$}; + \end{scope} + + \begin{scope}[shift={($(B)!0.5!(C)$)}, rotate=-70] + \draw[fill=gray!30] (0,0) -- (-180:0.25cm) arc (180:90:0.25cm); + \draw (140:0.15cm) node {$\cdot$}; + \end{scope} + + \begin{scope}[shift={($(A)!0.5!(B)$)}] + \draw[fill=gray!30] (0,0) -- (-180:0.25cm) arc (180:90:0.25cm); + \draw (140:0.15cm) node {$\cdot$}; + \end{scope} + + % Mittelsenkrechten + % y = m * x + t + % Für die Mittelsenkrechte m_AB gilt ($(A)!0.5!(B)$) ist auf m_AB + % m = - (delta x) / (delta y) = - (A.x - B.x) / (A.y - B.y) + % t = y - m*x + + % AB + \draw[color=cAchse, thick] (1.6cm,-0.3) -- node {} (1.6cm, 4.2cm); + + % AC + % (0.8, 2) \in Mittelsenkrechte auf b + % m = - (-1.6)/(-4) = - 0.4 + % t = 2 + 0.4 * 0.8 = 2.32 + % y = -0.4 * x + 2.32 + % (0, 2.32) und (3, 1.12) + \draw[color=cMittelsenkrechten] (0,2.32) -- node {} (3, 1.12); + + % Umkreismittelpunkt + % x = 1.6 + % y = -0.4*1.6 + 2.32 = 1.68 + \node [circle,inner sep=1pt,fill=cMittelsenkrechten] at (1.6,1.68) {}; + + % ((3.2+1.6)/2, (0+4)/2) ) = (2.4, 2) \in Mittelsenkrechte auf a + % 2 = m * 2.4 + t + % m_BC = delta y / delta x = (0-4)/(3.2-1.6) = -2.5 = -5/2 + % m = 2/5 + % t = y - m*x = 2 - 2.4 * 2/5 = 1.04 + % => y = 2/5 * x + 1.04 + % (0, 1.04) und (3, 2.24) + \draw[color=cMittelsenkrechten] (0, 1.04) -- node {} (3, 2.24); + + % Seitenhalbierende + \draw[color=cSeitenhalbierende,dashed] (A) -- node {} ($(B)!0.5!(C)$); + \draw[color=cSeitenhalbierende,dashed] (B) -- node {} ($(A)!0.5!(C)$); + %\draw[color=red, dashed] (C) -- node {} ($(A)!0.5!(B)$); + + % Schwerpunkt + % x = 1.6 + \node [circle,inner sep=1pt,fill=cSeitenhalbierende] at (1.6,1.34) {}; + + % Winkelhalbierende + % apex angle = 44° => alpha = 68° => 34° + \draw[color=cWinkelhalbierende, densely dashed] (A) -- node {} (34:4); + + \begin{scope}[shift={($(B)$)}] + \draw (146:4) node (BEnd) {}; + \end{scope} + + \draw[color=cWinkelhalbierende, densely dashed] (B) -- node {} (BEnd); + %\draw[color=red, dashed] (C) -- node {} ($(A)!0.5!(B)$); + + % Inkreismittelpunkt + % x = 1.6 + % tan(68/2) = y/x => y = tan(34)*x = 1.48 + \node [circle,inner sep=1pt,fill=cWinkelhalbierende] at (1.6,1.08) {}; + + + % Draw the triangle + \node[isosceles triangle, isosceles triangle apex angle=44,draw, + inner sep=0pt,anchor=lower side,rotate=90,draw=black, + line width=1.5pt, minimum height=4cm] + (triangle) at (1.6,-0.05) {}; + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/isosceles-triangle/Makefile b/tikz/isosceles-triangle/Makefile new file mode 100644 index 0000000..c8169ae --- /dev/null +++ b/tikz/isosceles-triangle/Makefile @@ -0,0 +1,25 @@ +SOURCE = isosceles-triangle +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/isosceles-triangle/isosceles-triangle.tex b/tikz/isosceles-triangle/isosceles-triangle.tex new file mode 100644 index 0000000..ac263cb --- /dev/null +++ b/tikz/isosceles-triangle/isosceles-triangle.tex @@ -0,0 +1,40 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{shapes, calc} +\begin{document} +\begin{preview} +\begin{tikzpicture} + + \node[isosceles triangle, isosceles triangle apex angle=44,draw, + inner sep=0pt,anchor=lower side,rotate=90,draw=black, + line width=1.5pt, minimum height=4cm, fill=gray!2] (triangle) at (1.6,-0.05) {}; + + \draw[fill=green!30] (0,0) -- (0:0.50cm) arc (0:68:.50cm); + \begin{scope}[shift={(3.2cm,0cm)}] + \draw[fill=green!30] (0,0) -- (-180:0.50cm) arc (180:110:0.5cm); + \draw (150:0.35cm) node {$\beta$}; + \end{scope} + + \begin{scope}[shift={(1.6cm,4cm)}] + \draw[fill=red!30] (0,0) -- (250:.75cm) arc (250:292:.75cm); + \draw (-90:0.5cm) node {$\gamma$}; + \end{scope} + + \coordinate[label=left:$A$] (A) at (0,0); + \coordinate[label=right:$B$] (B) at (3.2,0); + \coordinate[label=above:$C$] (C) at (1.6,4); + + \coordinate[label=below:$c$](c) at ($ (A)!.5!(B) $); + \coordinate[label=left:$b$](b) at ($ (A)!.5!(C) $); + \coordinate[label=right:$a$](a) at ($ (B)!.5!(C) $); + + \node[isosceles triangle, isosceles triangle apex angle=44,draw, + inner sep=0pt,anchor=lower side,rotate=90,draw=black, + line width=1.5pt, minimum height=4cm] (triangle) at (1.6,-0.05) {}; + + \coordinate[label=45:$\alpha$] (Alpha) at (A); + \end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/parse-tree/Makefile b/tikz/parse-tree/Makefile new file mode 100644 index 0000000..2d810cb --- /dev/null +++ b/tikz/parse-tree/Makefile @@ -0,0 +1,25 @@ +SOURCE = parse-tree +DELAY = 80 +DENSITY = 300 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/parse-tree/parse-tree.tex b/tikz/parse-tree/parse-tree.tex new file mode 100644 index 0000000..6788614 --- /dev/null +++ b/tikz/parse-tree/parse-tree.tex @@ -0,0 +1,32 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{shapes, calc} +\tikzstyle{vertex}=[draw,fill=black!15,circle,minimum size=20pt,inner sep=0pt] + +\begin{document} +\begin{preview} +\begin{tikzpicture}[font=\sffamily,thick,level/.style={sibling distance=50mm/#1}] + \node[vertex] {S} + child { + node[vertex] {A} + child { + node[vertex] {a} + } + child { + node[vertex] {A} + child { node[vertex] {a} } + child { + node[vertex] {A} + child { node[vertex] {$\varepsilon$} } + } + } + } child { + node[vertex] {B} + child { node[vertex] {b} } + } + ; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/path/Makefile b/tikz/path/Makefile new file mode 100644 index 0000000..ced3272 --- /dev/null +++ b/tikz/path/Makefile @@ -0,0 +1,31 @@ +SOURCE = path +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/path/path.tex b/tikz/path/path.tex new file mode 100644 index 0000000..057cb2a --- /dev/null +++ b/tikz/path/path.tex @@ -0,0 +1,34 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{arrows,positioning, calc} +\tikzstyle{vertex}=[draw,fill=black!15,circle,minimum size=20pt,inner sep=0pt] +\tikzstyle{selected edge} = [draw,line width=5pt,-,red!50] + +\begin{document} +\pgfdeclarelayer{background} +\pgfsetlayers{background,main} + +\begin{preview} +\begin{tikzpicture} [scale=1.2] + \node (a)[vertex] at (0,2) {a}; + \node (b)[vertex] at (1,1) {b}; + \node (c)[vertex] at (3,2) {c}; + \node (d)[vertex] at (4,1) {d}; + \node (e)[vertex] at (2,0) {e}; + \node (f)[vertex] at (1,3) {f}; + \node (g)[vertex] at (5,3) {g}; + \node (h)[vertex] at (0,1) {h}; + + \foreach \from/\to in {a/f,f/g,h/b,b/c,c/d,d/e,e/b,f/c} + \draw (\from) -- (\to); + + \begin{pgfonlayer}{background} + \foreach \from/\to in {a/f,f/c,c/d,d/e,e/b,b/h} + \draw (\from.center) edge[selected edge] (\to.center); + \end{pgfonlayer} +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/red-black-tree-small/Makefile b/tikz/red-black-tree-small/Makefile new file mode 100644 index 0000000..7de028e --- /dev/null +++ b/tikz/red-black-tree-small/Makefile @@ -0,0 +1,31 @@ +SOURCE = red-black-tree +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/red-black-tree-small/red-black-tree.tex b/tikz/red-black-tree-small/red-black-tree.tex new file mode 100644 index 0000000..bc43b57 --- /dev/null +++ b/tikz/red-black-tree-small/red-black-tree.tex @@ -0,0 +1,27 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{trees,arrows,positioning, calc} +\tikzstyle{redVertex} =[draw,fill=red, circle,minimum size=18pt,inner sep=0pt, text=white] +\tikzstyle{blackVertex}=[draw,fill=black, circle,minimum size=18pt,inner sep=0pt, text=white] +\tikzstyle{nil} =[draw,fill=black,rectangle,minimum size=18pt,inner sep=0pt, text=white] + +\begin{document} +\begin{preview} +\begin{tikzpicture}[font=\sffamily,very thick,level/.style={sibling distance=80mm/#1}] +\node [blackVertex] (r){2} + child { + node [blackVertex] {1} + child {node [nil] {NIL}} + child {node [nil] {NIL}} + } + child { + node [blackVertex] {3} + child {node [nil] {NIL}} + child {node [nil] {NIL}} + }; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/red-black-tree/Makefile b/tikz/red-black-tree/Makefile new file mode 100644 index 0000000..7de028e --- /dev/null +++ b/tikz/red-black-tree/Makefile @@ -0,0 +1,31 @@ +SOURCE = red-black-tree +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/red-black-tree/red-black-tree.tex b/tikz/red-black-tree/red-black-tree.tex new file mode 100644 index 0000000..fc632a0 --- /dev/null +++ b/tikz/red-black-tree/red-black-tree.tex @@ -0,0 +1,76 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{trees,arrows,positioning, calc} +\tikzstyle{redVertex} =[draw,fill=red, circle,minimum size=18pt,inner sep=0pt, text=white] +\tikzstyle{blackVertex}=[draw,fill=black, circle,minimum size=18pt,inner sep=0pt, text=white] +\tikzstyle{nil} =[draw,fill=black,rectangle,minimum size=18pt,inner sep=0pt, text=white] + +\begin{document} +\begin{preview} +\begin{tikzpicture}[font=\sffamily,very thick,level/.style={sibling distance=80mm/#1}] +\node [blackVertex] (r){8} + child { + node [blackVertex] {3} + child { + node [redVertex] {2} + child { + node [blackVertex] {-3} + child { + node [redVertex] {-4} + child {node [nil] {NIL}} + child {node [nil] {NIL}} + } + } + child { + node [blackVertex] {2} + child {node [nil] {NIL}} + child {node [nil] {NIL}} + } + } + child { + node [blackVertex] {6} + child { + node [redVertex] {5} + child {node [nil] {NIL}} + child {node [nil] {NIL}} + } + child { + node [redVertex] {7} + child {node [nil] {NIL}} + child {node [nil] {NIL}} + } + } + } + child { + node [blackVertex] {17} + child { + node [blackVertex] {9} + child { + node [redVertex] {11} + child {node [nil] {NIL}} + child {node [nil] {NIL}} + } + } + child { + node [redVertex] {19} + child { + node [blackVertex] {17} + child { + node [redVertex] {17} + child {node [nil] {NIL}} + child {node [nil] {NIL}} + } + } + child { + node [blackVertex] {20} + child {node [nil] {NIL}} + child {node [nil] {NIL}} + } + } + }; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/right-triangle/Makefile b/tikz/right-triangle/Makefile new file mode 100644 index 0000000..7ee6f9c --- /dev/null +++ b/tikz/right-triangle/Makefile @@ -0,0 +1,31 @@ +SOURCE = right-triangle +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/right-triangle/right-triangle.tex b/tikz/right-triangle/right-triangle.tex new file mode 100644 index 0000000..00a2c55 --- /dev/null +++ b/tikz/right-triangle/right-triangle.tex @@ -0,0 +1,53 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{shapes, calc, shapes,snakes} +\usepackage{amsmath,amssymb} + +\begin{document} +\begin{preview} +\begin{tikzpicture} + \newcommand\XC{4} + \newcommand\ALPHA{30} + + \newcommand\XB{{(\XC*(cos(\ALPHA)*cos(\ALPHA) - sin(\ALPHA)*sin(\ALPHA)) + \XC)*0.5}} + \newcommand\YB{{sqrt(cos(\ALPHA)*\XC*cos(\ALPHA)*\XC - (\XC*(cos(\ALPHA)*cos(\ALPHA) - sin(\ALPHA)*sin(\ALPHA)) + \XC)*0.5*(\XC*(cos(\ALPHA)*cos(\ALPHA) - sin(\ALPHA)*sin(\ALPHA)) + \XC)*0.5)}} + + % Draw the triangle + \draw[fill=gray!10] (0, 0) coordinate (A) + -- (\XB,\YB) coordinate (C) + -- (\XC, 0) coordinate (B) + -- (0, 0); + + % Draw nodes + \node at (A)[anchor=north] {A}; + \node at (B)[anchor=north] {B}; + \node at (C)[anchor=south] {C}; + + % Draw edge text + \node (c) at ($(A)!0.50!(B)$) [below,font=\tiny] {Hypothenuse}; + \node (b) at ($(A)!0.50!(C)$) [above,rotate=\ALPHA,font=\tiny] + {Ankathete zu Winkel $\alpha$}; + \node (a) at ($(B)!0.35!(C)$) [above,rotate={\ALPHA-90},font=\tiny] + {\parbox{2cm}{Gegenkathete\\ zu Winkel $\alpha$}}; + + + % draw alpha + \draw[fill=green!30] (0,0) -- (0:0.75cm) arc (0:\ALPHA:.75cm); + \coordinate[label=right:$\alpha$] (Alpha) at (0.25,0.15); + + % draw beta + \begin{scope}[shift={(\XC, 0)}] + \draw[fill=red!30] (0,0) -- (-180:0.50cm) arc (180:{180-(90-\ALPHA)}:0.5cm); + \draw (150:0.35cm) node {$\beta$}; + \end{scope} + + % draw gamma + \begin{scope}[shift={(\XB, \YB)}] + \draw[fill=blue!30] (0,0) -- ({180+\ALPHA}:0.5cm) arc ({180+\ALPHA}:{180+\ALPHA+90}:0.5cm); + \draw (-0.1, -0.05) node[below] {$\gamma$}; + \end{scope} +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/singly-linked-list/Makefile b/tikz/singly-linked-list/Makefile new file mode 100644 index 0000000..b28f80c --- /dev/null +++ b/tikz/singly-linked-list/Makefile @@ -0,0 +1,31 @@ +SOURCE = singly-linked-list +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/singly-linked-list/singly-linked-list.tex b/tikz/singly-linked-list/singly-linked-list.tex new file mode 100644 index 0000000..96c3c0f --- /dev/null +++ b/tikz/singly-linked-list/singly-linked-list.tex @@ -0,0 +1,44 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{calc,shapes.multipart,chains,arrows} + +\tikzset{ + squarecross/.style={ + draw, rectangle,minimum size=18pt, fill=orange!80, + inner sep=0pt, text=black, + path picture = { + \draw[black] + (path picture bounding box.north west) -- + (path picture bounding box.south east) + (path picture bounding box.south west) -- + (path picture bounding box.north east); + } + } +} + +\begin{document} +\begin{preview} +\begin{tikzpicture}[ + list/.style={ + very thick, rectangle split, + rectangle split parts=2, draw, + rectangle split horizontal, minimum size=18pt, + inner sep=4pt, text=black, + rectangle split part fill={red!20, blue!20} + }, + ->, start chain, very thick + ] + + \node[list,on chain] (A) {12}; + \node[list,on chain] (B) {99}; + \node[list,on chain] (C) {37}; + \node[squarecross] (D) [right=of C] {}; + \draw[*->] let \p1 = (A.two), \p2 = (A.center) in (\x1,\y2) -- (B); + \draw[*->] let \p1 = (B.two), \p2 = (B.center) in (\x1,\y2) -- (C); + \draw[*->] let \p1 = (C.two), \p2 = (C.center) in (\x1,\y2) -- (D); +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/stack/Makefile b/tikz/stack/Makefile new file mode 100644 index 0000000..bd8afd1 --- /dev/null +++ b/tikz/stack/Makefile @@ -0,0 +1,31 @@ +SOURCE = stack +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/stack/stack.tex b/tikz/stack/stack.tex new file mode 100644 index 0000000..63f6382 --- /dev/null +++ b/tikz/stack/stack.tex @@ -0,0 +1,19 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\usepackage{tikz} +\usetikzlibrary{shapes.multipart} + +\begin{document} +\begin{preview} +\begin{tikzpicture}[stack/.style={rectangle split, rectangle split parts=#1,draw, anchor=center, fill=white}] +\node[stack=5] { +\nodepart{two}a +\nodepart{three}c +\nodepart{four}c +\nodepart{five}b +}; +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/teststrategien-anschaulich/Makefile b/tikz/teststrategien-anschaulich/Makefile new file mode 100644 index 0000000..85bf96c --- /dev/null +++ b/tikz/teststrategien-anschaulich/Makefile @@ -0,0 +1,31 @@ +SOURCE = teststrategien-anschaulich +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/teststrategien-anschaulich/teststrategien-anschaulich.tex b/tikz/teststrategien-anschaulich/teststrategien-anschaulich.tex new file mode 100644 index 0000000..858f469 --- /dev/null +++ b/tikz/teststrategien-anschaulich/teststrategien-anschaulich.tex @@ -0,0 +1,51 @@ +\documentclass{article} + +\usepackage[utf8]{inputenc} % this is needed for umlauts +\usepackage[ngerman]{babel} % this is needed for umlauts +\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf + +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{shapes, calc, shapes,snakes, automata} +\usepackage{amsmath,amssymb} + +\tikzstyle{midnode}=[ + draw=blue!70, % draw the border with 70% transparent blue + rectangle, % the shape of the node is a rectangle + fill=blue!10, % fill the box with 20% blue + text width=1cm, + text centered] + +\tikzstyle{smallnode}=[ + draw=blue!70, % draw the border with 70% transparent blue + rectangle, % the shape of the node is a rectangle + fill=blue!10, % fill the box with 20% blue + text width=0.4cm, + text centered] + +\begin{document} +\begin{preview} +\begin{tikzpicture}[->,>=stealth,auto, very thick, scale=5] + % Draw the vertices. + \node[midnode] (s) {Start}; + \node[smallnode, right of=s, node distance=1.8cm] (a) {1}; + \node[smallnode, below of=a] (b) {2}; + \node[smallnode, right of=a, node distance=1.8cm] (c) {3}; + \node[smallnode, below of=c] (d) {4}; + \node[smallnode, right of=c, node distance=1.8cm] (e) {5}; + \node[midnode, below of=e] (x) {Stopp}; + + % Connect vertices with edges + \path (s) edge node {} (a); + \path (a) edge node {} (c); + \path (a) edge node {} (b); + \path (b) edge node {} (c); + \path (c) edge node {} (d); + \path (c) edge node {} (e); + \path (d) edge node {} (e); + \path (e) edge node {} (x); + +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/teststrategien/Makefile b/tikz/teststrategien/Makefile new file mode 100644 index 0000000..71cb21d --- /dev/null +++ b/tikz/teststrategien/Makefile @@ -0,0 +1,31 @@ +SOURCE = teststrategien +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/teststrategien/teststrategien.tex b/tikz/teststrategien/teststrategien.tex new file mode 100644 index 0000000..a565d29 --- /dev/null +++ b/tikz/teststrategien/teststrategien.tex @@ -0,0 +1,61 @@ +\documentclass{article} + +\usepackage[utf8]{inputenc} % this is needed for umlauts +\usepackage[ngerman]{babel} % this is needed for umlauts +\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf + +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{shapes, calc, shapes,snakes, automata} +\usepackage{amsmath,amssymb} + +\tikzstyle{textnode}=[ + draw=blue!70, % draw the border with 70% transparent blue + rectangle, % the shape of the node is a rectangle + fill=blue!10, % fill the box with 20% blue + text width=4cm, + inner xsep=3pt, + text centered] + +\tikzstyle{smallnode}=[ + draw=blue!70, % draw the border with 70% transparent blue + rectangle, % the shape of the node is a rectangle + fill=blue!10, % fill the box with 20% blue + text width=1cm, + text centered] + +\begin{document} +\begin{preview} +\begin{tikzpicture}[->,>=stealth,auto, very thick] + % Draw the vertices. + \node[textnode] (a) {Pfadüberdeckung}; + \node[textnode, below of=a, node distance=4cm] (b) {Zweigüberdeckung}; + \node[textnode, below of=b] (c) {Anweisungsüberdeckung}; + + \node[textnode, right of=a, node distance=5cm] (d) {Mehrfache\\Bedingungsüberdeckung}; + \node[textnode, below of=d, node distance=2cm] (e) {Minimal-mehrfache Bedinungsüberdeckung}; + \node[textnode, below of=e, node distance=2.2cm] (f) {Einfache\\Bedinungsüberdeckung}; + + % Legende + \node[smallnode, below of=c, node distance=1.5cm] (x) {x}; + \node[smallnode, below of=x] (y) {y}; + \draw (x.south) -- (y.north) + node [midway, + right of=x, + node distance=3cm, + draw=none, + text width=4cm] + {Testverfahren x\\subsummiert\\Testverfahren y}; + + % Connect vertices with edges and draw weights + \path (a) edge node {} (b); + \path (b) edge node {} (c); + \path (d) edge node {} (e); + \path (e) edge node {} (f); + \path (e) edge node {} (b.east); + + \path (x) edge node {} (y); +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/triangle/Makefile b/tikz/triangle/Makefile new file mode 100644 index 0000000..e11bdf0 --- /dev/null +++ b/tikz/triangle/Makefile @@ -0,0 +1,31 @@ +SOURCE = triangle +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/triangle/triangle.tex b/tikz/triangle/triangle.tex new file mode 100644 index 0000000..93d7416 --- /dev/null +++ b/tikz/triangle/triangle.tex @@ -0,0 +1,56 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{shapes, calc, shapes,snakes} +\usepackage{amsmath,amssymb} + +\begin{document} +\begin{preview} +\begin{tikzpicture}[thick] + \newcommand\XC{4} + \newcommand\ALPHA{30} + + \newcommand\XB{{(\XC*(cos(\ALPHA)*cos(\ALPHA) - sin(\ALPHA)*sin(\ALPHA)) + \XC)*0.5}} + \newcommand\YB{{sqrt(cos(\ALPHA)*\XC*cos(\ALPHA)*\XC - (\XC*(cos(\ALPHA)*cos(\ALPHA) - sin(\ALPHA)*sin(\ALPHA)) + \XC)*0.5*(\XC*(cos(\ALPHA)*cos(\ALPHA) - sin(\ALPHA)*sin(\ALPHA)) + \XC)*0.5)}} + + % Draw the triangle + \draw[fill=gray!10] (0, 0) coordinate (A) + -- (\XB,\YB) coordinate (C) + -- (\XC, 0) coordinate (B) + -- (0, 0); + + % Draw nodes + \node at (A)[anchor=north] {A}; + \node at (B)[anchor=north] {B}; + \node at (C)[anchor=south] {C}; + + % Draw edge text + \node (c) at ($(A)!0.5!(B)$) [below] {c}; + \node (b) at ($(A)!0.5!(C)$) [above] {b}; + \node (a) at ($(B)!0.6!(C)$) [right] {a}; + + + % draw alpha + \draw[fill=green!30] (0,0) -- (0:0.75cm) arc (0:\ALPHA:.75cm); + \coordinate[label=right:$\alpha$] (Alpha) at (0.25,0.15); + + % draw beta + \begin{scope}[shift={(\XC, 0)}] + \draw[fill=red!30] (0,0) -- (-180:0.50cm) arc (180:{180-(90-\ALPHA)}:0.5cm); + \draw (150:0.35cm) node {$\beta$}; + \end{scope} + + % draw gamma + \begin{scope}[shift={(\XB, \YB)}] + \draw[fill=blue!30] (0,0) -- ({180+\ALPHA}:0.5cm) arc ({180+\ALPHA}:{180+\ALPHA+90}:0.5cm); + \draw (-0.1, -0.05) node[below] {$\gamma$}; + \end{scope} + + \draw (0, 0) coordinate (X) + -- (\XB,\YB) coordinate (Y) + -- (\XC, 0) coordinate (Z) + -- (0, 0); +\end{tikzpicture} +\end{preview} +\end{document} diff --git a/tikz/url-structure/Makefile b/tikz/url-structure/Makefile new file mode 100644 index 0000000..1a765de --- /dev/null +++ b/tikz/url-structure/Makefile @@ -0,0 +1,31 @@ +SOURCE = url-structure +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux + +gif: + pdfcrop $(SOURCE).pdf + convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif + make clean + +png: + make + make svg + inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png + +transparentGif: + convert $(SOURCE).pdf -transparent white result.gif + make clean + +svg: + #inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg + pdf2svg $(SOURCE).pdf $(SOURCE).svg + # Necessary, as pdf2svg does not always create valid svgs: + inkscape $(SOURCE).svg --export-plain-svg=$(SOURCE).svg diff --git a/tikz/url-structure/url-structure.tex b/tikz/url-structure/url-structure.tex new file mode 100644 index 0000000..d832e16 --- /dev/null +++ b/tikz/url-structure/url-structure.tex @@ -0,0 +1,43 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} +\usepackage{tikz} +\usetikzlibrary{shapes,snakes} +\usepackage{amsmath,amssymb} + +\begin{document} +\begin{preview} + + +% Define box and box title style +\tikzstyle{mybox} = [ + draw=red, + fill=blue!20, + very thick, + rectangle, + rounded corners, + inner sep=10pt, + inner ysep=20pt +] +\tikzstyle{fancytitle} =[fill=red, text=white] + + +\begin{tikzpicture} +\node [mybox] (box){ + \begin{minipage}{0.9\textwidth} + $\underbrace{\text{http}}_{\text{protocol}} + \text{://} + \underbrace{ + \overbrace{\text{martin-thoma}}^\text{2\textsuperscript{nd} level domain} + \text{.} + \overbrace{\text{com}}^\text{TLD} + }_\text{hostname} + \underbrace{\text{/why-to-study-math/}}_\text{path} + \text{\#} + \underbrace{\text{Math\_is\_fun}}_\text{Fragment identifier}$ + \end{minipage} +}; +\node[fancytitle, right=10pt] at (box.north west) {The URL}; +\end{tikzpicture} +\end{preview} +\end{document}