%
% polargleichung.tex -- Kegelschnitte in Polardarstellung
%
% (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule
%
\documentclass[tikz]{standalone}
\usepackage{amsmath}
\usepackage{times}
\usepackage{txfonts}
\usepackage{pgfplots}
\usepackage{csvsimple}
\usetikzlibrary{arrows,intersections,math,calc}
\begin{document}
\def\skala{2}
\definecolor{darkgreen}{rgb}{0,0.6,0}
\begin{tikzpicture}[>=latex,thick,scale=\skala]

\def\p{1}

\begin{scope}
\clip (-4,-3) rectangle (1.1,3);
\fill[color=blue!20]
	(0,1)
	--
	plot[domain=90:-90,samples=100] ({\x}:{\p/(1+cos(\x))})
	--
 	(0,-1) arc (-90:90:1)
	--
	cycle;

\fill[color=blue!20]
	(0,1) arc (90:270:1)
	--
	plot[domain=-90:-145,samples=20] ({\x}:{\p/(1+cos(\x))})
	--
	plot[domain=145:90,samples=20] ({\x}:{\p/(1+cos(\x))})
	--
	cycle;

\fill[color=darkgreen!20]
	plot[domain=90:-90,samples=100] ({\x}:{\p/(1+cos(\x))})
	-- cycle;

\fill[color=darkgreen!20]
	(0,1)
	--
	(0,3)
	--
	plot[domain=145:90,samples=20] ({\x}:{\p/(1+cos(\x))})
	--
	cycle;

\fill[color=darkgreen!20]
	(0,-1)
	--
	(0,-3)
	--
	plot[domain=-145:-90,samples=20] ({\x}:{\p/(1+cos(\x))})
	--
	cycle;

\end{scope}

\draw[->] (-4.1,0) -- (1.3,0) coordinate[label={$\varphi=0$}];
\draw (0,-3.1) -- (0,3.1);

\begin{scope}
\clip (-4,-3) rectangle (1.1,3);
\draw[color=red,line width=1.4pt] (0,0) circle[radius=1];
\foreach \e in {10,20,...,90}{
	\draw[color=blue!\e!red,line width=1.4pt]
		plot[domain=0:360,samples=100]
			(\x:{\p/(1+(\e/100)*cos(\x))});
}

\draw[color=blue,line width=1.4pt]
	plot[domain=-145:145,samples=100] ({\x}:{\p/(1+cos(\x))});

\foreach \e in {10,30,50,70,90}{
	\draw[color=darkgreen!\e!blue,line width=1.4pt]
		plot[domain={-138+\e/5}:{138-\e/5},samples=100]
			(\x:{\p/(1+((\e+100)/100)*cos(\x))});
}
\end{scope}

\fill[color=white] (0,1) circle[radius=0.04];
\draw (0,1) circle[radius=0.04];
\fill[color=white] (0,-1) circle[radius=0.04];
\draw (0,-1) circle[radius=0.04];
\node at (0,0.6) [left] {$p$};

\node at (0,0) [below left] {$O$};
\fill[color=white] (0,0) circle[radius=0.04];
\draw (0,0) circle[radius=0.04];

\node[color=red] at (45:1) [above right] {$\varepsilon=0$};
\node[color=red] at ($(45:1)+(0,0.2)$) [above right] {Kreis:};
\node[color=blue!70!red] at (-3.5,0.7) {$\varepsilon=0.7$};
\node[color=blue!70!red] at (-3.5,0.9) {Ellipse:};
\node[color=blue] at (-3.4,2.65) [rotate=-18] {Parabel: $\varepsilon=1$};
\node[color=darkgreen!90!blue] at (-1,2.8) [right] {Hyperbel: $\varepsilon=1.9$};

%\draw[color=yellow]
%	plot[domain=90:-90,samples=100] ({\x}:{\p/(1+cos(\x))});

\end{tikzpicture}
\end{document}

