mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-19 11:38:05 +02:00
misc
This commit is contained in:
parent
13a8a4bdea
commit
6a645ad80d
12 changed files with 288 additions and 0 deletions
37
pstricks/car-bottom/Makefile
Normal file
37
pstricks/car-bottom/Makefile
Normal file
|
@ -0,0 +1,37 @@
|
|||
SOURCE = car-bottom
|
||||
DELAY = 80
|
||||
DENSITY = 300
|
||||
WIDTH = 512
|
||||
|
||||
make:
|
||||
latex $(SOURCE).tex -output-format=pdf
|
||||
dvips -D600 $(SOURCE).dvi -o $(SOURCE).ps
|
||||
ps2pdf $(SOURCE).ps $(SOURCE).pdf
|
||||
make clean
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot *.dvi *.ps
|
||||
|
||||
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
|
3
pstricks/car-bottom/Readme.md
Normal file
3
pstricks/car-bottom/Readme.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Compiled example
|
||||
----------------
|
||||

|
BIN
pstricks/car-bottom/car-bottom.png
Normal file
BIN
pstricks/car-bottom/car-bottom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
15
pstricks/car-bottom/car-bottom.tex
Normal file
15
pstricks/car-bottom/car-bottom.tex
Normal file
|
@ -0,0 +1,15 @@
|
|||
\documentclass{standalone}
|
||||
\usepackage{pst-solides3d}
|
||||
\begin{document}
|
||||
\begin{pspicture}(-4,-2)(3,3)
|
||||
\psset{viewpoint=80 -60 50,Decran=50}
|
||||
\psSolid[object=cylindre,h=1,r=1,action=draw*,mode=4,fillcolor=green!20,RotX=90] (+5,+3,0) % Rad vorne rechts
|
||||
\psSolid[object=cylindre,h=1,r=1,action=draw*,mode=4,fillcolor=green!20,RotX=90] (-5,+3,0) % Rad hinten rechts
|
||||
\psSolid[object=parallelepiped,a=12,b=3,c=2,action=draw*,fillcolor=yellow!20](0,0,0) % body
|
||||
\psSolid[object=cylindre,h=1,r=1,action=draw*,mode=4,fillcolor=green!20,RotX=90] (+5,-3,0) % Rad vorne links
|
||||
\psSolid[object=cylindre,h=1,r=1,action=draw*,mode=4,fillcolor=green!20,RotX=90] (-5,-3,0) % Rad hinten links
|
||||
\psSolid[object=cylindre,h=6,r=0.1,action=draw*,mode=4,fillcolor=gray!20,RotX=90] (-5,+3,0) % axis back
|
||||
\psSolid[object=cylindre,h=6,r=0.1,action=draw*,mode=4,fillcolor=gray!20,RotX=90] (+5,+3,0) % axis front
|
||||
%\axesIIID[showOrigin=false](1,1,1)(3,2,2.5)
|
||||
\end{pspicture}
|
||||
\end{document}
|
49
source-code/Minted-Haskell/Arithmetik.hs
Normal file
49
source-code/Minted-Haskell/Arithmetik.hs
Normal file
|
@ -0,0 +1,49 @@
|
|||
module Arithmetik where
|
||||
|
||||
-- Aufgabe 1.1
|
||||
-- Berechnung der Potenz durch e-faches multiplizieren von b
|
||||
-- Benötigt e Rekursionsschritte
|
||||
pow1 :: Double -> Int -> Double
|
||||
pow1 b 0 = 1
|
||||
pow1 b e = b * (pow1 b (e-1))
|
||||
|
||||
-- Aufgabe 1.2
|
||||
-- Berechnung der Potenz pow2(b,e) = b^e
|
||||
-- Benötigt O(log_2(e)) Rekursionsschritte
|
||||
pow2 :: Double -> Int -> Double
|
||||
pow2 b 0 = 1
|
||||
pow2 b e = if odd e
|
||||
then b * pow2 b (e-1)
|
||||
else pow2 (b*b) (quot e 2)
|
||||
|
||||
-- Aufgabe 1.3
|
||||
-- Berechnung der Potenz pow3(b,e) = b^e mit einer Hilfsfunktion
|
||||
pow3 :: Double -> Integer -> Double
|
||||
pow3 b e
|
||||
| e < 0 = error "Der Exponent muss nicht-negativ sein"
|
||||
| otherwise = pow3h b e 1 where
|
||||
pow3h b e acc
|
||||
| e == 0 = acc
|
||||
| odd e = pow3h b (e-1) (acc*b)
|
||||
| otherwise = pow3h (b*b) (quot e 2) acc
|
||||
|
||||
-- Aufgabe 1.4
|
||||
-- Suche größte natürliche Zahl x, sodass x^e <= r
|
||||
-- Prinzipiell könnte e auch Double sein, aber wenn x und e
|
||||
-- natürliche Zahlen sind, könnte man o.B.d.A r abrunden.
|
||||
root :: Int -> Int -> Int
|
||||
root e r = rootH 0 r
|
||||
where rootH a b
|
||||
| b-a == 1 = a
|
||||
| floor (pow1 (fromIntegral(quot (a+b) 2)) e) <= r = rootH (quot (a+b) 2) b
|
||||
| otherwise = rootH a (quot (a+b) 2)
|
||||
|
||||
-- Aufgabe 1.5: Primzahlcheck
|
||||
isPrime :: Integer -> Bool
|
||||
isPrime 0 = False
|
||||
isPrime 1 = False
|
||||
isPrime x = not (hasDivisor (root 2 x) 2)
|
||||
where hasDivisor upperBound i
|
||||
| i > upperBound = False
|
||||
| mod x i == 0 = True
|
||||
| otherwise = hasDivisor upperBound (i+1)
|
9
source-code/Minted-Haskell/Makefile
Normal file
9
source-code/Minted-Haskell/Makefile
Normal file
|
@ -0,0 +1,9 @@
|
|||
SOURCE = Minted-Haskell
|
||||
|
||||
make:
|
||||
pdflatex -shell-escape $(SOURCE).tex -output-format=pdf
|
||||
pdflatex -shell-escape $(SOURCE).tex -output-format=pdf
|
||||
make clean
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) *.class *.html *.log *.aux *.out *.glo *.glg *.gls *.ist *.xdy *.1 *.toc *.pyg
|
34
source-code/Minted-Haskell/Minted-Haskell.tex
Normal file
34
source-code/Minted-Haskell/Minted-Haskell.tex
Normal file
|
@ -0,0 +1,34 @@
|
|||
\documentclass[a4paper,12pt]{article}
|
||||
\usepackage{amssymb} % needed for math
|
||||
\usepackage{amsmath} % needed for math
|
||||
\usepackage[utf8]{inputenc} % this is needed for german umlauts
|
||||
\usepackage[ngerman]{babel} % this is needed for german umlauts
|
||||
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
|
||||
\usepackage[margin=2cm]{geometry} %layout
|
||||
\usepackage{minted} % needed for the inclusion of source code
|
||||
|
||||
\usepackage{fancyhdr}
|
||||
\pagestyle{fancy}
|
||||
\lhead{Martin Thoma, Tutorium 4}
|
||||
\rhead{Programmierparadigmen, Blatt 1}
|
||||
|
||||
\begin{document}
|
||||
\renewcommand{\theFancyVerbLine}{
|
||||
\sffamily\textcolor[rgb]{0.5,0.5,0.5}{\scriptsize\arabic{FancyVerbLine}}}
|
||||
\inputminted[linenos,
|
||||
numbersep=7pt,
|
||||
gobble=0,
|
||||
frame=lines,
|
||||
framesep=2mm,
|
||||
label=Arithmetik.hs,
|
||||
fontsize=\footnotesize, tabsize=4]{haskell}{Arithmetik.hs}
|
||||
\clearpage
|
||||
\inputminted[linenos,
|
||||
numbersep=7pt,
|
||||
gobble=0,
|
||||
frame=lines,
|
||||
framesep=2mm,
|
||||
label=ColorClassification.java,
|
||||
fontsize=\footnotesize, tabsize=4]{haskell}{Sort.hs}
|
||||
|
||||
\end{document}
|
54
source-code/Minted-Haskell/Sort.hs
Normal file
54
source-code/Minted-Haskell/Sort.hs
Normal file
|
@ -0,0 +1,54 @@
|
|||
module Sort where
|
||||
|
||||
-- Aufgabe 2
|
||||
-- insert list el: sorts an elmenet el into a sorted list
|
||||
insert :: (Ord t) => [t] -> t -> [t]
|
||||
insert [] x = [x]
|
||||
insert [a] x
|
||||
| x < a = [x, a]
|
||||
| otherwise = [a, x]
|
||||
insert (a:b:qs) x
|
||||
| x < a = [x,a,b] ++ qs
|
||||
| x < b = [a,x,b] ++ qs
|
||||
| otherwise = [a,b] ++ insert qs x
|
||||
|
||||
-- sortH q r: Sorts an unsorted list r into a sorted list q
|
||||
insertH :: (Ord t) => [t] -> [t] -> [t]
|
||||
insertH q [] = q
|
||||
insertH q [r] = insert q r
|
||||
insertH q (r:rest) = insertH (insert q r) rest
|
||||
|
||||
-- insertSort list: sorts list
|
||||
insertSort :: (Ord t) => [t] -> [t]
|
||||
insertSort [] = []
|
||||
insertSort [a] = [a]
|
||||
insertSort (a:qs) = insertH [a] qs
|
||||
|
||||
-- Aufgabe 3
|
||||
merge :: (Ord t) => [t] -> [t] -> [t]
|
||||
merge [] x = x
|
||||
merge x [] = x
|
||||
merge (x:xs) (y:ys)
|
||||
| x <= y = x : merge xs (y:ys)
|
||||
| otherwise = y : merge ys (x:xs)
|
||||
|
||||
mergeSort :: (Ord t) => [t] -> [t]
|
||||
mergeSort [] = []
|
||||
mergeSort [x] = [x]
|
||||
mergeSort xs = merge (mergeSort top) (mergeSort bottom) where
|
||||
(top, bottom) = splitAt (div (length xs) 2) xs
|
||||
|
||||
-- Aufgabe 4
|
||||
-- Teste
|
||||
isSorted :: (Ord t) => [t] -> Bool
|
||||
isSorted [] = True
|
||||
isSorted [a] = True
|
||||
isSorted (a:b:xs)
|
||||
| (a <= b) && isSorted xs = True
|
||||
| otherwise = False
|
||||
|
||||
insertSortedIsSorted :: (Ord t) => [t] -> Bool
|
||||
insertSortedIsSorted xs = isSorted(insertSort xs)
|
||||
|
||||
mergeSortedIsSorted :: (Ord t) => [t] -> Bool
|
||||
mergeSortedIsSorted xs = isSorted(mergeSort xs)
|
31
tikz/topology-continuous-mapping/Makefile
Normal file
31
tikz/topology-continuous-mapping/Makefile
Normal file
|
@ -0,0 +1,31 @@
|
|||
SOURCE = topology-continuous-mapping
|
||||
DELAY = 80
|
||||
DENSITY = 300
|
||||
WIDTH = 512
|
||||
|
||||
make:
|
||||
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:
|
||||
#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
|
3
tikz/topology-continuous-mapping/Readme.md
Normal file
3
tikz/topology-continuous-mapping/Readme.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Compiled example
|
||||
----------------
|
||||

|
BIN
tikz/topology-continuous-mapping/topology-continuous-mapping.png
Normal file
BIN
tikz/topology-continuous-mapping/topology-continuous-mapping.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -0,0 +1,53 @@
|
|||
\documentclass[varwidth=true, border=2pt]{standalone}
|
||||
\usepackage{amsmath,amssymb}
|
||||
\usepackage{pgfplots}
|
||||
\usepackage{tikz}
|
||||
\usepackage{tkz-fct}
|
||||
\usetikzlibrary{shapes.misc}
|
||||
|
||||
\begin{document}
|
||||
\tikzset{
|
||||
point/.style={
|
||||
thick,
|
||||
draw=gray,
|
||||
cross out,
|
||||
inner sep=0pt,
|
||||
minimum width=4pt,
|
||||
minimum height=4pt,
|
||||
},
|
||||
}
|
||||
\begin{tikzpicture}
|
||||
|
||||
\draw[->] (-0.5,0) -- (1.5,0) node [below] {$\mathbb{R}$};
|
||||
|
||||
\foreach \x in {0,...,1}
|
||||
\draw (\x,0.1) -- (\x,-0.1) node [below] {\x};
|
||||
|
||||
|
||||
\draw[red] (0.07,0.1) -- (0,0.1) -- (0,-0.1) -- (0.07,-0.1) node [below] {};
|
||||
\draw[red] plot [smooth] coordinates{(0.47,0.1) (0.5,0) (0.47,-0.1)};
|
||||
|
||||
\begin{scope}[shift={(4,0)}]
|
||||
\draw[thick] (0cm,0cm) circle(1cm);
|
||||
\draw[thick, red] ([shift={(180:1cm)}]-0.0,0) arc (180:0:1cm);
|
||||
\draw (0:1cm) node[point, label=right:{$0$}] {};
|
||||
%\path node[point, blue, label={[blue,above]{$\overline{a}$}}] (posU) at (-252:1cm) {};
|
||||
%\path node[label={[red,left]{$U$}}] at (30:1cm) {};
|
||||
\end{scope}
|
||||
|
||||
\coordinate (circleUp) at (2.6, 0.1);
|
||||
\coordinate (circleDown) at (2.6,-0.1);
|
||||
\coordinate (numberlineUp) at (1.7, 0.1);
|
||||
\coordinate (numberlineDown) at (1.7,-0.1);
|
||||
|
||||
\path[->] (numberlineUp) edge [bend left] node[label=$f$] {} (circleUp);
|
||||
\path[<-] (numberlineDown) edge [bend right] node[label=below:$g$] {} (circleDown);
|
||||
|
||||
%\draw (3.7cm,0cm) node[point, blue, label={[blue,above]{$a$}}] (posA) {};
|
||||
%\draw (0.7cm,0cm) node[point, blue, label={[blue,above]{$\pi^{-1}(u)$}}] {};
|
||||
%\draw[dashed, blue, thick] plot [smooth] coordinates{(posU) (0.2,-0.8) (2.5,-1) (posA)};
|
||||
|
||||
%\draw[blue, dashed, thick] (3.7cm,0cm) arc (0:180:1.5 and 0.5);
|
||||
|
||||
\end{tikzpicture}
|
||||
\end{document}
|
Loading…
Add table
Add a link
Reference in a new issue