Seite 1 von 1

Füllen des von mehreren Pfaden eingeschlossenen Raumes

Verfasst: So 17. Okt 2021, 14:44
von ruho1803

Hallo Latex-Community,

ich bin noch nicht wirklich erfahren mit Tikz und möchte eine Grafik erstellen, in der durch eine blaue Füllung der zulässige Bereich für (θn, θm) angezeigt wird. Die Beschränkungen ergeben sich durch die eingezeichneten Linien.

  • Beide Winkel müssen kleiner sein als 90
  • es besteht ein linearer Zusammenhang zwischen den Winkeln, nämlich θm< θn +40 und θm< θn -40

irgendwie müsste das mit \fill funktionieren, aber ich bin leider noch nicht dahinter gestiegen, wie das hier bei mehreren einschließenden Pfaden funktioniert.

\documentclass[a4paper, 12pt]{article}
\usepackage[ngerman]{babel}\usepackage[utf8]{inputenc}
\usepackage{amsfonts}\usepackage{amssymb}\usepackage{amsmath}\usepackage{mathtools}
\usepackage{eurosym}\usepackage{wasysym}\usepackage{graphicx}\usepackage{tikz}\usepackage{adjustbox}\usetikzlibrary{shapes.misc} \usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfdeclarelayer{bg}
\pgfsetlayers{bg,main}
\begin{document}
	\begin{tikzpicture}[ cross/.style={draw, cross out,
			minimum size=2*(#1-1pt), inner sep=0pt, outer sep=0pt}, x=.05cm, y=.05cm]
		%Raster zeichnen
		\draw [color=gray!40]  [step=5mm] (-110,-110) grid (110,110);
		% Achsen zeichnen
		\draw[->,thick] (-100,0) -- (100,0) node[right] {$\theta_n$};
		\draw[->,thick] (0,-100) -- (0,100) node[above] {$\theta_m$};
		% Achsen beschriften
		\foreach \x in {-80, -60, -40, -20, 20, 40, 60,80}
		\draw (\x,-1) -- (\x,1) node[below=4pt] {$\scriptstyle\x$};
		\foreach \y in {-80, -60, -40, -20, 20, 40, 60,80}
		\draw (-1,\y) -- (1,\y) node[left=4pt] {$\scriptstyle\y$};
		%Funktionen zeichnen:
		\clip(-108,-108) rectangle (108,108);
		\draw[smooth, domain=-95:95, name path=A] plot (\x, 90) node[above, xshift = -4cm] {$\overline{\theta_m}$};  
\draw[smooth, domain=-95:95, name path = B] plot (\x, -90) node[below, xshift = -3cm] {$\underline{\theta_m}$}; \draw[thick, name path = C] (90,95) -- (90,-95) node[right, yshift=4cm] {$\overline{\theta_n}$};
\draw[thick, name path = D] (-90,95) -- (-90,-95) node[left, yshift = 4cm] {$\underline{\theta_n}$};
\draw[smooth, domain=-95:95, name path = E] plot (\x, \x - 40) node[right, xshift = -4cm, yshift = -4.5cm] {$F{n,m}$};
\draw[smooth, domain=-95:95, name path = F] plot (\x, \x + 40) node[left, xshift = -6cm, yshift = -5.5cm] {$-F{n,m}$}; \end{tikzpicture} \end{document}

Im Anhang habe ich eine grobe Skizze wie ich mir das vorstelle. Der schraffierte Bereich sollte ausgemalt werden mit \fill [opacity=0.5,blue].


Re: Füllen des von mehreren Pfaden eingeschlossenen Raumes

Verfasst: So 17. Okt 2021, 19:14
von Bartman

Du kannst das Einfügen der Achsen und der Werte an diesen auch pgfplots überlassen.

Man kann den gewünschten Bereich färben, indem man sich an den Schnittpunkten der Geraden und Strecken orientiert:

\documentclass[tikz]{standalone}
\usetikzlibrary{intersections,decorations.markings}

\begin{document}
\begin{tikzpicture}[
	plot label/.style 2 args={
	    postaction={
            decorate,
            decoration={
                markings,
                mark=at position #1 with \node #2;
            }
        }
    },
    every plot/.style={domain=-95:95},
	x=.05cm, y=.05cm
]
%Raster zeichnen
\draw [color=gray!40, step=5mm] (-110,-110) grid (110,110);
% Achsen zeichnen
\path[->, thick, at end] 
	(-100,0) edge node [right] {$\theta_n$} (100,0) 
	(0,-100) edge node [above] {$\theta_m$} (0,100)
;
% Achsen beschriften
\foreach \coord in {-80, -60, -40, -20, 20, 40, 60, 80}
	\draw 
		(\coord,-1) -- (\coord,1) node [below=4pt] {$\scriptstyle\coord$}
		(-1,\coord) -- (1,\coord) node [left=4pt] {$\scriptstyle\coord$}
	;
%Funktionen zeichnen:
\clip (-108,-108) rectangle (108,108);

\draw[
    name path=A, 
    plot label={.58}{[above]{$\overline{\theta_m}$}}
] plot (\x, 90);

\draw[
    name path = B,
    plot label={.69}{[below]{$\underline{\theta_m}$}}
] plot (\x, -90);

\draw[thick, name path = C] 
    (90,95) -- 
        node [pos=.58, right] {$\overline{\theta_n}$} 
    (90,-95)
;

\draw[thick, name path = D] 
    (-90,95) -- 
        node[pos=.58, left] {$\underline{\theta_n}$} 
    (-90,-95) 
;

\draw[
    name path = E, 
    plot label={.6}{[below right]{$F*{n,m}$}}
] plot (\x, \x - 40);

\draw[
    name path = F,
    plot label={.4}{[above left]{$-F*{n,m}$}}
] plot (\x, \x + 40);

\fill [
    name intersections={of=A and F, by=isAF}, 
    name intersections={of=D and F, by=isDF},
    name intersections={of=B and E, by=isBE},
    name intersections={of=C and E, by=isCE},
    opacity=.5, 
    blue
]
    (isAF) -- (isDF) |- (isBE) -- (isCE) |- cycle
;
\end{tikzpicture} 
\end{document}

Re: Füllen des von mehreren Pfaden eingeschlossenen Raumes

Verfasst: Mo 18. Okt 2021, 15:15
von ruho1803

Das hat wunderbar geklappt, vielen Dank!


Re: Füllen des von mehreren Pfaden eingeschlossenen Raumes

Verfasst: Mo 18. Okt 2021, 19:57
von Bartman

Ein Hinweis auf nachträgliche Änderungen:

Dank der Bibliothek für Dekorationen kann man die Beschriftung einer mit TikZ gezeichneten Funktion abhängig von dieser platzieren.