mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-19 11:38:05 +02:00
added two images
This commit is contained in:
parent
98227cbdd2
commit
c4a77fb34e
12 changed files with 465 additions and 0 deletions
35
tikz/center-line/Makefile
Normal file
35
tikz/center-line/Makefile
Normal file
|
@ -0,0 +1,35 @@
|
|||
SOURCE = center-line
|
||||
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:
|
||||
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
|
BIN
tikz/center-line/center-line.png
Normal file
BIN
tikz/center-line/center-line.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
75
tikz/center-line/center-line.tex
Normal file
75
tikz/center-line/center-line.tex
Normal file
|
@ -0,0 +1,75 @@
|
|||
\documentclass{article}
|
||||
\usepackage[pdftex,active,tightpage]{preview}
|
||||
\setlength\PreviewBorder{2mm}
|
||||
\usepackage{tikz}
|
||||
\usepackage{tkz-fct}
|
||||
\usetikzlibrary{shapes.misc}
|
||||
\usetikzlibrary{shapes, calc, shapes,snakes}
|
||||
\usepackage{amsmath,amssymb}
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{tikzpicture}[cross/.style={ thick,
|
||||
draw=gray,
|
||||
cross out,
|
||||
inner sep=0pt,
|
||||
minimum width=4pt,
|
||||
minimum height=4pt},
|
||||
dot/.style={ thick,
|
||||
draw=gray,
|
||||
circle,
|
||||
fill=black,
|
||||
inner sep=0pt,
|
||||
minimum width=4pt,
|
||||
minimum height=4pt}]
|
||||
\node at (0,3) {Schritt 1:};
|
||||
\foreach \point in {(2,3),(4,3),(6,3),(8,3),(10,3),(12,3)}{
|
||||
\node[cross] at \point {};
|
||||
}
|
||||
\foreach \point in {(3,3),(11,3)}{
|
||||
\node[dot] at \point {};
|
||||
}
|
||||
|
||||
\draw[->] (2,3) edge[bend left] (2.9,3);
|
||||
\draw[->] (12,3) edge[bend right] (11.1,3);
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\node at (0,2) {Schritt 2:};
|
||||
\foreach \point in {(3,2),(4,2),(6,2),(8,2),(10,2),(11,2)}{
|
||||
\node[cross] at \point {};
|
||||
}
|
||||
\foreach \point in {(3.5,2),(4.33,2),(9.66,2),(10.5,2)}{
|
||||
\node[dot] at \point {};
|
||||
}
|
||||
|
||||
\draw[->] (3,2) edge[bend left] (3.4,2);
|
||||
\draw[->] (4,2) edge[bend left] (4.2,2);
|
||||
\draw[->] (11,2) edge[bend right] (10.6,2);
|
||||
\draw[->] (10,2) edge[bend right] (9.73,2);
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\node at (0,1) {Schritt 3:};
|
||||
\node[cross] at (7,1) {};
|
||||
|
||||
\node at (0,1.6) {$\vdots$};
|
||||
\node at (0,2.6) {$\vdots$};
|
||||
|
||||
|
||||
% Brace
|
||||
\draw [decorate,decoration={brace,amplitude=6pt},yshift=3pt]
|
||||
(2,3) -- (4,3) node [black,midway,yshift=12pt]
|
||||
{\footnotesize 200m};
|
||||
\draw [decorate,decoration={brace,amplitude=6pt},yshift=3pt]
|
||||
(4,3) -- (6,3) node [black,midway,yshift=12pt]
|
||||
{\footnotesize 200m};
|
||||
\draw [decorate,decoration={brace,amplitude=6pt},yshift=3pt]
|
||||
(6,3) -- (8,3) node [black,midway,yshift=12pt]
|
||||
{\footnotesize 200m};
|
||||
\draw [decorate,decoration={brace,amplitude=6pt},yshift=3pt]
|
||||
(8,3) -- (10,3) node [black,midway,yshift=12pt]
|
||||
{\footnotesize 200m};
|
||||
\draw [decorate,decoration={brace,amplitude=6pt},yshift=3pt]
|
||||
(10,3) -- (12,3) node [black,midway,yshift=12pt]
|
||||
{\footnotesize 200m};
|
||||
|
||||
\end{tikzpicture}
|
||||
\end{preview}
|
||||
\end{document}
|
40
tikz/center-line/tikz.py
Normal file
40
tikz/center-line/tikz.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
from random import uniform
|
||||
import random
|
||||
import math
|
||||
|
||||
n = 5
|
||||
xMin, yMin = 0, 0
|
||||
xMax, yMax = 5, 5
|
||||
xSum = 0
|
||||
ySum = 0
|
||||
coordinates = []
|
||||
|
||||
random.seed(42)
|
||||
|
||||
for i in range(n):
|
||||
x = uniform(xMin, xMax)
|
||||
y = uniform(yMin, yMax)
|
||||
xSum += x
|
||||
ySum += y
|
||||
coordinates.append((x,y))
|
||||
|
||||
center = (float(xSum) / n, float(ySum) / n)
|
||||
|
||||
cx, cy = center
|
||||
pointCoords = ""
|
||||
for p in coordinates:
|
||||
px, py = p
|
||||
newP = "(%.2f,%.2f)," % (px, py)
|
||||
pointCoords = newP + pointCoords
|
||||
deltaY = cy-py
|
||||
deltaX = cx-px
|
||||
length = (deltaY**2+deltaX**2)**0.5
|
||||
sinAlpha = deltaY/length
|
||||
cosAlpha = deltaX/length
|
||||
print("\draw[->] (%.2f,%.2f) -- (%.2f,%.2f);" % (px, py, px+cosAlpha*length*0.80, py+sinAlpha*length*0.80))
|
||||
|
||||
print("\\node[circle,inner sep=1pt,fill] at (%.2f,%.2f) {};" % (cx, cy))
|
||||
|
||||
print("\\foreach \point in {" + pointCoords + "}{")
|
||||
print("\\node[dot] at \point {};")
|
||||
print("}")
|
35
tikz/center-two-cluster/Makefile
Normal file
35
tikz/center-two-cluster/Makefile
Normal file
|
@ -0,0 +1,35 @@
|
|||
SOURCE = center-two-cluster
|
||||
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:
|
||||
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
|
BIN
tikz/center-two-cluster/center-two-cluster.png
Normal file
BIN
tikz/center-two-cluster/center-two-cluster.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
47
tikz/center-two-cluster/center-two-cluster.tex
Normal file
47
tikz/center-two-cluster/center-two-cluster.tex
Normal file
|
@ -0,0 +1,47 @@
|
|||
\documentclass{article}
|
||||
\usepackage[pdftex,active,tightpage]{preview}
|
||||
\setlength\PreviewBorder{2mm}
|
||||
\usepackage{tikz}
|
||||
\usepackage{tkz-fct}
|
||||
\usetikzlibrary{shapes.misc}
|
||||
\usetikzlibrary{shapes, calc, shapes,snakes}
|
||||
\usepackage{amsmath,amssymb}
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{tikzpicture}[scale=0.1,dot/.style={ thick,
|
||||
draw=gray,
|
||||
cross out,
|
||||
inner sep=0pt,
|
||||
minimum width=4pt,
|
||||
minimum height=4pt}]
|
||||
|
||||
\draw[->] (-3.43,8.41) -- (-0.69,1.68);
|
||||
\draw[->] (-5.48,3.65) -- (-1.10,0.73);
|
||||
\draw[->] (2.52,-7.45) -- (0.50,-1.49);
|
||||
\draw[->] (2.97,-3.76) -- (0.59,-0.75);
|
||||
\draw[->] (3.43,-0.85) -- (0.69,-0.17);
|
||||
\draw[->] (15.00,0.00) -- (3.00,0.00);
|
||||
\node[circle,inner sep=1pt,fill] at (0.00,0.00) {};
|
||||
\foreach \point in {(15.00,0.00),(3.43,-0.85),(2.97,-3.76),(2.52,-7.45),(-5.48,3.65),(-3.43,8.41)}{
|
||||
\node[dot] at \point {};
|
||||
}
|
||||
\draw[->] (39.63,0.85) -- (39.93,0.17);
|
||||
\draw[->] (43.27,-8.94) -- (40.65,-1.79);
|
||||
\draw[->] (38.54,9.68) -- (39.71,1.94);
|
||||
\draw[->] (34.19,-5.01) -- (38.84,-1.00);
|
||||
\draw[->] (44.37,3.43) -- (40.87,0.69);
|
||||
\draw[->] (25.00,0.00) -- (37.00,0.00);
|
||||
\node[circle,inner sep=1pt,fill] at (40.00,0.00) {};
|
||||
\foreach \point in {(25.00,0.00),(44.37,3.43),(34.19,-5.01),(38.54,9.68),(43.27,-8.94),(39.63,0.85)}{
|
||||
\node[dot] at \point {};
|
||||
}
|
||||
\node[circle,inner sep=1pt,fill] at (40.00,0.00) {};
|
||||
\foreach \point in {(15,0), (35,0)}{
|
||||
\node[dot] at \point {};
|
||||
}
|
||||
|
||||
\end{tikzpicture}
|
||||
\end{preview}
|
||||
\end{document}
|
||||
|
129
tikz/center-two-cluster/tikz.py
Normal file
129
tikz/center-two-cluster/tikz.py
Normal file
|
@ -0,0 +1,129 @@
|
|||
from random import uniform
|
||||
import random
|
||||
import math
|
||||
|
||||
print """\documentclass{article}
|
||||
\usepackage[pdftex,active,tightpage]{preview}
|
||||
\setlength\PreviewBorder{2mm}
|
||||
\usepackage{tikz}
|
||||
\usepackage{tkz-fct}
|
||||
\usetikzlibrary{shapes.misc}
|
||||
\usetikzlibrary{shapes, calc, shapes,snakes}
|
||||
\usepackage{amsmath,amssymb}
|
||||
|
||||
\\begin{document}
|
||||
\\begin{preview}
|
||||
\\begin{tikzpicture}[scale=0.1,dot/.style={ thick,
|
||||
draw=gray,
|
||||
cross out,
|
||||
inner sep=0pt,
|
||||
minimum width=4pt,
|
||||
minimum height=4pt}]
|
||||
"""
|
||||
|
||||
def getPositionFromOffset(px, py, angle, radius):
|
||||
x = px + radius * math.cos(math.radians(angle))
|
||||
y = py + radius * math.sin(math.radians(angle))
|
||||
return (x, y)
|
||||
|
||||
n = 5
|
||||
xSum = 0
|
||||
ySum = 0
|
||||
coordinates = [(0,0)]
|
||||
|
||||
random.seed(13)
|
||||
|
||||
for i in range(n-1):
|
||||
radius = uniform(0,20)
|
||||
angle = uniform(0, 360)
|
||||
px, py = coordinates[-1]
|
||||
x, y = getPositionFromOffset(px, py, angle, radius)
|
||||
xSum += x
|
||||
ySum += y
|
||||
coordinates.append((x,y))
|
||||
|
||||
center = (float(xSum) / n, float(ySum) / n)
|
||||
|
||||
cx, cy = center
|
||||
coordinates.append((cx+15, cy))
|
||||
|
||||
pointCoords = ""
|
||||
for p in coordinates:
|
||||
px, py = p
|
||||
px -= cx
|
||||
py -= cy
|
||||
newP = "(%.2f,%.2f)," % (px, py)
|
||||
pointCoords = newP + pointCoords
|
||||
deltaY = 0-py
|
||||
deltaX = 0-px
|
||||
length = (deltaY**2+deltaX**2)**0.5
|
||||
sinAlpha = deltaY/length
|
||||
cosAlpha = deltaX/length
|
||||
print("\draw[->] (%.2f,%.2f) -- (%.2f,%.2f);" % (px, py, px+cosAlpha*length*0.80, py+sinAlpha*length*0.80))
|
||||
|
||||
print("\\node[circle,inner sep=1pt,fill] at (%.2f,%.2f) {};" % (0, 0))
|
||||
|
||||
print("\\foreach \point in {" + pointCoords[:-1] + "}{")
|
||||
print("\\node[dot] at \point {};")
|
||||
print("}")
|
||||
|
||||
################################################################################
|
||||
random.seed(17)
|
||||
xSum = 0
|
||||
ySum = 0
|
||||
coordinates = [(0,0)]
|
||||
for i in range(n-1):
|
||||
radius = uniform(0,20)
|
||||
angle = uniform(0, 360)
|
||||
px, py = coordinates[-1]
|
||||
x, y = getPositionFromOffset(px, py, angle, radius)
|
||||
xSum += x
|
||||
ySum += y
|
||||
coordinates.append((x,y))
|
||||
|
||||
center = (float(xSum) / n, float(ySum) / n)
|
||||
|
||||
cx, cy = center
|
||||
coordinates.append((cx-15,cy))
|
||||
xOffset = 40
|
||||
cTmp = []
|
||||
for p in coordinates:
|
||||
px, py = p
|
||||
cTmp.append((px-cx+xOffset,py-cy))
|
||||
|
||||
coordinates = cTmp
|
||||
cx, cy = xOffset, 0
|
||||
pointCoords = ""
|
||||
|
||||
for p in coordinates:
|
||||
px, py = p
|
||||
newP = "(%.2f,%.2f)," % (px, py)
|
||||
pointCoords = newP + pointCoords
|
||||
deltaY = -py
|
||||
deltaX = xOffset-px
|
||||
length = (deltaY**2+deltaX**2)**0.5
|
||||
sinAlpha = deltaY/length
|
||||
cosAlpha = deltaX/length
|
||||
print("\draw[->] (%.2f,%.2f) -- (%.2f,%.2f);" % (px, py, px+cosAlpha*length*0.80, py+sinAlpha*length*0.80))
|
||||
|
||||
|
||||
print("\\node[circle,inner sep=1pt,fill] at (%.2f,%.2f) {};" % (xOffset, 0))
|
||||
|
||||
print("\\foreach \point in {" + pointCoords[:-1] + "}{")
|
||||
print("\\node[dot] at \point {};")
|
||||
print("}")
|
||||
|
||||
##################################
|
||||
|
||||
print("\\node[circle,inner sep=1pt,fill] at (%.2f,%.2f) {};" % (xOffset, 0))
|
||||
|
||||
print("\\foreach \point in {(15,0), (35,0)}{")
|
||||
print("\\node[dot] at \point {};")
|
||||
print("}")
|
||||
|
||||
|
||||
print """
|
||||
\end{tikzpicture}
|
||||
\end{preview}
|
||||
\end{document}
|
||||
"""
|
35
tikz/center/Makefile
Normal file
35
tikz/center/Makefile
Normal file
|
@ -0,0 +1,35 @@
|
|||
SOURCE = center
|
||||
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:
|
||||
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
|
BIN
tikz/center/center.png
Normal file
BIN
tikz/center/center.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
29
tikz/center/center.tex
Normal file
29
tikz/center/center.tex
Normal file
|
@ -0,0 +1,29 @@
|
|||
\documentclass{article}
|
||||
\usepackage[pdftex,active,tightpage]{preview}
|
||||
\setlength\PreviewBorder{2mm}
|
||||
\usepackage{tikz}
|
||||
\usepackage{tkz-fct}
|
||||
\usetikzlibrary{shapes.misc}
|
||||
\usetikzlibrary{shapes, calc, shapes,snakes}
|
||||
\usepackage{amsmath,amssymb}
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{tikzpicture}[dot/.style={ thick,
|
||||
draw=gray,
|
||||
cross out,
|
||||
inner sep=0pt,
|
||||
minimum width=4pt,
|
||||
minimum height=4pt}]
|
||||
\draw[->] (3.20,0.13) -- (3.01,0.86);
|
||||
\draw[->] (1.38,1.12) -- (2.65,1.06);
|
||||
\draw[->] (3.68,3.38) -- (3.11,1.51);
|
||||
\draw[->] (4.46,0.43) -- (3.26,0.92);
|
||||
\draw[->] (2.11,0.15) -- (2.79,0.86);
|
||||
\node[circle,inner sep=1pt,fill] at (2.97,1.04) {};
|
||||
\foreach \point in {(2.11,0.15),(4.46,0.43),(3.68,3.38),(1.38,1.12),(3.20,0.13)}{
|
||||
\node[dot] at \point {};
|
||||
}
|
||||
\end{tikzpicture}
|
||||
\end{preview}
|
||||
\end{document}
|
40
tikz/center/tikz.py
Normal file
40
tikz/center/tikz.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
from random import uniform
|
||||
import random
|
||||
import math
|
||||
|
||||
n = 5
|
||||
xMin, yMin = 0, 0
|
||||
xMax, yMax = 5, 5
|
||||
xSum = 0
|
||||
ySum = 0
|
||||
coordinates = []
|
||||
|
||||
random.seed(42)
|
||||
|
||||
for i in range(n):
|
||||
x = uniform(xMin, xMax)
|
||||
y = uniform(yMin, yMax)
|
||||
xSum += x
|
||||
ySum += y
|
||||
coordinates.append((x,y))
|
||||
|
||||
center = (float(xSum) / n, float(ySum) / n)
|
||||
|
||||
cx, cy = center
|
||||
pointCoords = ""
|
||||
for p in coordinates:
|
||||
px, py = p
|
||||
newP = "(%.2f,%.2f)," % (px, py)
|
||||
pointCoords = newP + pointCoords
|
||||
deltaY = cy-py
|
||||
deltaX = cx-px
|
||||
length = (deltaY**2+deltaX**2)**0.5
|
||||
sinAlpha = deltaY/length
|
||||
cosAlpha = deltaX/length
|
||||
print("\draw[->] (%.2f,%.2f) -- (%.2f,%.2f);" % (px, py, px+cosAlpha*length*0.80, py+sinAlpha*length*0.80))
|
||||
|
||||
print("\\node[circle,inner sep=1pt,fill] at (%.2f,%.2f) {};" % (cx, cy))
|
||||
|
||||
print("\\foreach \point in {" + pointCoords + "}{")
|
||||
print("\\node[dot] at \point {};")
|
||||
print("}")
|
Loading…
Add table
Add a link
Reference in a new issue