From 61d718505418511856dcb7251c409e8211dbfdec Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Tue, 11 Jun 2013 21:59:02 +0200 Subject: [PATCH] misc --- documents/some-text-styling/Makefile | 7 +++ .../some-text-styling/some-text-styling.tex | 13 +++++ .../Euklidischer-Algorithmus.tex | 50 +++++++++++++++++++ .../Euklidischer-Algorithmus/Makefile | 36 +++++++++++++ .../Euklidischer-Algorithmus/basiswechsel.py | 22 ++++++++ .../Horner-Schema/Horner-Schema.tex | 42 ++++++++++++++++ source-code/Pseudocode/Horner-Schema/Makefile | 36 +++++++++++++ .../Pseudocode/Horner-Schema/basiswechsel.py | 20 ++++++++ ...circle-inscribed-circumscribed-polygon.tex | 4 +- 9 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 documents/some-text-styling/Makefile create mode 100644 documents/some-text-styling/some-text-styling.tex create mode 100644 source-code/Pseudocode/Euklidischer-Algorithmus/Euklidischer-Algorithmus.tex create mode 100644 source-code/Pseudocode/Euklidischer-Algorithmus/Makefile create mode 100644 source-code/Pseudocode/Euklidischer-Algorithmus/basiswechsel.py create mode 100644 source-code/Pseudocode/Horner-Schema/Horner-Schema.tex create mode 100644 source-code/Pseudocode/Horner-Schema/Makefile create mode 100644 source-code/Pseudocode/Horner-Schema/basiswechsel.py diff --git a/documents/some-text-styling/Makefile b/documents/some-text-styling/Makefile new file mode 100644 index 0000000..7b2afc1 --- /dev/null +++ b/documents/some-text-styling/Makefile @@ -0,0 +1,7 @@ +SOURCE = some-text-styling +make: + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.out diff --git a/documents/some-text-styling/some-text-styling.tex b/documents/some-text-styling/some-text-styling.tex new file mode 100644 index 0000000..3708e3d --- /dev/null +++ b/documents/some-text-styling/some-text-styling.tex @@ -0,0 +1,13 @@ +\documentclass{scrartcl} + +\begin{document} +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam est sapien, rutrum ut vehicula quis, mollis vel nisi. Aliquam et velit et enim ullamcorper facilisis. Morbi dictum lobortis aliquam. Fusce ornare nisl sed urna posuere cursus. Nulla suscipit eros sit amet orci blandit convallis. Nunc interdum condimentum enim, ullamcorper fermentum urna blandit vel. Nunc laoreet metus vel mauris eleifend at suscipit odio tincidunt. Fusce fermentum lorem non lorem tempor porttitor convallis purus tincidunt. Mauris lacinia odio eget sapien scelerisque non lobortis nisi lacinia. + +\begin{enumerate} + \item {\bf abcdefghijklmnopqrstuvwxyz} + \item {\bfseries{abcdefghijklmnopqrstuvwxyz}} + \item {\textbf{abcdefghijklmnopqrstuvwxyz}} +\end{enumerate} + +Morbi at ante in nunc gravida adipiscing. In arcu lectus, dapibus nec posuere ut, faucibus nec magna. Nullam non magna quam. Nullam eleifend pretium pharetra. Vestibulum hendrerit blandit bibendum. In odio ante, porttitor in imperdiet non, porta at mi. Nullam vitae ipsum urna, laoreet gravida risus. Cras a lacus at est dictum commodo eu sit amet risus. Aenean suscipit magna enim. Curabitur tincidunt neque tellus. Etiam vitae viverra risus. +\end{document} diff --git a/source-code/Pseudocode/Euklidischer-Algorithmus/Euklidischer-Algorithmus.tex b/source-code/Pseudocode/Euklidischer-Algorithmus/Euklidischer-Algorithmus.tex new file mode 100644 index 0000000..463a581 --- /dev/null +++ b/source-code/Pseudocode/Euklidischer-Algorithmus/Euklidischer-Algorithmus.tex @@ -0,0 +1,50 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\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{amssymb,amsmath,amsfonts} % nice math rendering +\usepackage{braket} % needed for \Set +\usepackage{algorithm,algpseudocode} + +\usepackage{tikz} +\usetikzlibrary{decorations.pathreplacing,calc} +\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};} +\newcommand*{\AddNote}[4]{% + \begin{tikzpicture}[overlay, remember picture] + \draw [decoration={brace,amplitude=0.5em},decorate,very thick] + ($(#3)!(#1.north)!($(#3)-(0,1)$)$) -- + ($(#3)!(#2.south)!($(#3)-(0,1)$)$) + node [align=center, text width=2.5cm, pos=0.5, anchor=west] {#4}; + \end{tikzpicture} +}% + +\begin{document} +\begin{preview} + \begin{algorithm}[H] + \begin{algorithmic} + \Require $Z \in \mathbb{R}_{\geq 0}, b \in \mathbb{N}_{\geq 2}$ + \State $p\gets 0$\tikzmark{top} + \While{$b^p > Z$}\tikzmark{right} + \State $p\gets p+1$ + \EndWhile + \State $i\gets p-1$\tikzmark{bottom} + \\ + \While{$Z \neq 0$}\tikzmark{top2} + \State $y_i\gets Z\,\mbox{div}\, b^i$ + \State $R\gets Z\,\mbox{mod}\, b^i$ + \State $Z\gets R$ + \State $i\gets i-1$ + \EndWhile\tikzmark{bottom2} + \\ + \State \textbf{Ergebnis:} $y_{p-1} y_{p-2} \dots y_0, y_{-1} \dots y_{i+1}$ + \end{algorithmic} + \caption{Euklidischer Algorithmus zum Basiswechsel} + \AddNote{top}{bottom}{right}{Berechne $p$ sodass gilt: $b^p \leq Z < b^{p+1}$} + \AddNote{top2}{bottom2}{right}{In jedem Schritt wird eine Ziffer berechnet} + \label{alg:euclidBaseTransformation} + \end{algorithm} +\end{preview} +\end{document} diff --git a/source-code/Pseudocode/Euklidischer-Algorithmus/Makefile b/source-code/Pseudocode/Euklidischer-Algorithmus/Makefile new file mode 100644 index 0000000..95d7d2a --- /dev/null +++ b/source-code/Pseudocode/Euklidischer-Algorithmus/Makefile @@ -0,0 +1,36 @@ +SOURCE = Euklidischer-Algorithmus +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot + +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: + make + #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 + rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg + inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg + rm $(SOURCE)2.svg diff --git a/source-code/Pseudocode/Euklidischer-Algorithmus/basiswechsel.py b/source-code/Pseudocode/Euklidischer-Algorithmus/basiswechsel.py new file mode 100644 index 0000000..894f3c9 --- /dev/null +++ b/source-code/Pseudocode/Euklidischer-Algorithmus/basiswechsel.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +def euklid(b, Z): + p = 0 + while b**p <= Z: + p = p+1 + i = p - 1 + + y = {} + while Z != 0 and i > -5: + y[i] = Z // b**i + R = Z % b**i + Z = R + i = i -1 + return y + +if __name__ == "__main__": + r = euklid(16, 15741.233) + print("Result:") + for key in sorted(r.iterkeys(),reverse=True): + print "%s: %s" % (key, r[key]) diff --git a/source-code/Pseudocode/Horner-Schema/Horner-Schema.tex b/source-code/Pseudocode/Horner-Schema/Horner-Schema.tex new file mode 100644 index 0000000..8c767f2 --- /dev/null +++ b/source-code/Pseudocode/Horner-Schema/Horner-Schema.tex @@ -0,0 +1,42 @@ +\documentclass{article} +\usepackage[pdftex,active,tightpage]{preview} +\setlength\PreviewBorder{2mm} + +\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{amssymb,amsmath,amsfonts} % nice math rendering +\usepackage{braket} % needed for \Set +\usepackage{algorithm,algpseudocode} + +\usepackage{tikz} +\usetikzlibrary{decorations.pathreplacing,calc} +\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};} +\newcommand*{\AddNote}[4]{% + \begin{tikzpicture}[overlay, remember picture] + \draw [decoration={brace,amplitude=0.5em},decorate,very thick] + ($(#3)!(#1.north)!($(#3)-(0,1)$)$) -- + ($(#3)!(#2.south)!($(#3)-(0,1)$)$) + node [align=center, text width=2.5cm, pos=0.5, anchor=west] {#4}; + \end{tikzpicture} +}% + +\begin{document} +\begin{preview} + \begin{algorithm}[H] + \begin{algorithmic} + \Require $Z \in \mathbb{N}_{\geq 0}, b \in \mathbb{N}_{\geq 2}$ + \State $i\gets 0$ + \While{$Z > 0$} + \State $y_i\gets Z \mod b$ + \State $Z \gets \frac{Z - y_i}{b}$ + \State $i \gets i + 1$ + \EndWhile + \\ + \State \textbf{Ergebnis:} $y_{0} y_{1} \dots y_{i-1}$ + \end{algorithmic} + \caption{Horner-Schema zum Basiswechsel von Zahlen in $\mathbb{N}_0$} + \label{alg:hornerschemaGanzeZahlen} + \end{algorithm} +\end{preview} +\end{document} diff --git a/source-code/Pseudocode/Horner-Schema/Makefile b/source-code/Pseudocode/Horner-Schema/Makefile new file mode 100644 index 0000000..c44162b --- /dev/null +++ b/source-code/Pseudocode/Horner-Schema/Makefile @@ -0,0 +1,36 @@ +SOURCE = Horner-Schema +DELAY = 80 +DENSITY = 300 +WIDTH = 500 + +make: + pdflatex $(SOURCE).tex -output-format=pdf + pdflatex $(SOURCE).tex -output-format=pdf + make clean + +clean: + rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot + +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: + make + #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 + rsvg-convert -a -w $(WIDTH) -f svg $(SOURCE).svg -o $(SOURCE)2.svg + inkscape $(SOURCE)2.svg --export-plain-svg=$(SOURCE).svg + rm $(SOURCE)2.svg diff --git a/source-code/Pseudocode/Horner-Schema/basiswechsel.py b/source-code/Pseudocode/Horner-Schema/basiswechsel.py new file mode 100644 index 0000000..d913fc7 --- /dev/null +++ b/source-code/Pseudocode/Horner-Schema/basiswechsel.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +def string(zahl): + if zahl <= 9: + return str(zahl) + else: + return chr(55+zahl) + +def horner(b, Z): + ergebnis = '' + while Z > 0: + rest = Z % b + ergebnis = string(rest) + ergebnis + Z = (Z - rest)/b + return ergebnis + +if __name__ == "__main__": + r = horner(16, 31562) + print("Result:" + str(r)) diff --git a/tikz/circle-inscribed-circumscribed-polygon/circle-inscribed-circumscribed-polygon.tex b/tikz/circle-inscribed-circumscribed-polygon/circle-inscribed-circumscribed-polygon.tex index 7cd50c6..0802d67 100644 --- a/tikz/circle-inscribed-circumscribed-polygon/circle-inscribed-circumscribed-polygon.tex +++ b/tikz/circle-inscribed-circumscribed-polygon/circle-inscribed-circumscribed-polygon.tex @@ -6,7 +6,7 @@ \begin{document} \begin{tikzpicture} \newcommand{\R}{1.5} % radius of the circle - \newcommand{\n}{6} % edges of the polygon + \newcommand{\n}{12} % edges of the polygon % Center \path ( 0,0) coordinate (M); @@ -18,7 +18,7 @@ } \draw (0:0.3*\R) arc (0:360/\n:0.3*\R); \coordinate[label=right:$\alpha$] (Alpha) at ({2*360/(\n+2)}:0.1*\R); - \draw (i1) -- (i2) -- (i3) -- (i4) --(i5) -- (i6) -- cycle; + \draw (i1) \foreach \i in {2,...,\n} {-- (i\i)} -- cycle; % Circle \draw[green] (0,0) circle (\R);