%
% kartenkreis.tex -- template for standalon tikz images
%
% (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}
\begin{document}
\def\skala{3}
\begin{tikzpicture}[>=latex,thick,scale=\skala]

\definecolor{darkgreen}{rgb}{0,0.6,0}

\fill[color=red!20] (0,-1) rectangle (1.5,1);
\fill[color=blue!20] (-1.5,-1) rectangle (0,1);
\fill[color=darkgreen!40,opacity=0.5] (-1,0) rectangle (1,1.5);
\fill[color=orange!40,opacity=0.5] (-1,-1.5) rectangle (1,0);
\fill[color=white] (0,0) circle[radius=1];

\fill[color=gray!20]
	(0,-1.5) -- (0.02,-1.6) -- (0.5,-1.8) -- (0.98,-1.6) -- (1,-1.5)
	-- cycle;
\fill[color=gray!20]
	(0,1.5) -- (0.02,1.6) -- (0.5,1.8) -- (0.98,1.6) -- (1,1.5)
	-- cycle;
\fill[color=gray!20]
	(0,-1.5) -- (-0.02,-1.6) -- (-0.5,-1.8) -- (-0.98,-1.6) -- (-1,-1.5)
	-- cycle;
\fill[color=gray!20]
	(0,1.5) -- (-0.02,1.6) -- (-0.5,1.8) -- (-0.98,1.6) -- (-1,1.5)
	-- cycle;

\fill[color=gray!20]
	(1.5,0) -- (1.6,0.02) -- (1.8,0.5) -- (1.6,0.98) -- (1.5,1)
	-- cycle;
\fill[color=gray!20]
	(-1.5,0) -- (-1.6,0.02) -- (-1.8,0.5) -- (-1.6,0.98) -- (-1.5,1)
	-- cycle;
\fill[color=gray!20]
	(1.5,0) -- (1.6,-0.02) -- (1.8,-0.5) -- (1.6,-0.98) -- (1.5,-1)
	-- cycle;
\fill[color=gray!20]
	(-1.5,0) -- (-1.6,-0.02) -- (-1.8,-0.5) -- (-1.6,-0.98) -- (-1.5,-1)
	-- cycle;

\draw[->] (0.5,-1.8) arc (-180:-90:0.1) arc (-90:0:1.3) arc (0:90:0.1);
\draw[->] (1.8,0.5) arc (-90:0:0.1) arc (0:90:1.3) arc (90:180:0.1);
\draw[->] (-0.5,1.8) arc (0:90:0.1) arc (90:180:1.3) arc (180:270:0.1);
\draw[->] (-1.8,-0.5) arc (90:180:0.1) arc (180:270:1.3) arc (270:360:0.1);

\node at (1.01,1.32)
	[right] {$\varphi_3\circ \varphi_1^{-1}(y)=\sqrt{1-y^2}$};
\node at (1.6,1.6) {$\varphi_{31}$};

\node at (1.01,-1.28)
	[right] {$\varphi_1\circ \varphi_4^{-1}(x)=-\sqrt{1-x^2}$};
\node at (1.6,-1.6) {$\varphi_{14}$};

\node at (-1.24,1.32)
	[left] {$\varphi_2\circ\varphi_4^{-1}(x)=\sqrt{1-x^2}$};
\node at (-1.6,-1.6) {$\varphi_{42}$};

\node at (-1.18,-1.28)
	[left] {$\varphi_4\circ\varphi_2^{-1}(y)=-\sqrt{1-y^2}$};
\node at (-1.6,1.6) {$\varphi_{23}$};

\foreach \y in {0.1,0.3,...,0.9}{
	\draw[->,color=red,shorten >= 0.1cm,shorten <= 0.3cm]
		({sqrt(1-\y*\y)},{\y}) -- (1.5,\y);
	\draw[->,color=red,shorten >= 0.1cm,shorten <= 0.3cm]
		({sqrt(1-\y*\y)},{-\y}) -- (1.5,-\y);
	\draw[->,color=blue,shorten >= 0.1cm,shorten <= 0.3cm]
		({-sqrt(1-\y*\y)},{\y}) -- (-1.5,\y);
	\draw[->,color=blue,shorten >= 0.1cm,shorten <= 0.3cm]
		({-sqrt(1-\y*\y)},{-\y}) -- (-1.5,-\y);
}
\foreach \x in {0.1,0.3,...,0.9}{
	\draw[->,color=darkgreen,shorten >= 0.1cm,shorten <= 0.3cm]
		({\x},{sqrt(1-\x*\x)}) -- ({\x},1.5);
	\draw[->,color=darkgreen,shorten >= 0.1cm,shorten <= 0.3cm]
		({-\x},{sqrt(1-\x*\x)}) -- ({-\x},1.5);
	\draw[->,color=orange,shorten >= 0.1cm,shorten <= 0.3cm]
		({\x},{-sqrt(1-\x*\x)}) -- ({\x},-1.5);
	\draw[->,color=orange,shorten >= 0.1cm,shorten <= 0.3cm]
		({-\x},{-sqrt(1-\x*\x)}) -- ({-\x},-1.5);
}

\draw[color=gray!20,line width=3pt] (0,0) circle[radius=1];

\def\r{1.02}

\begin{scope}
	\clip (0,-1.1) rectangle (1.1,1.1);
	\draw[color=red,line width=1.4pt] (-89:\r) arc (-89:89:\r);
	\draw[color=red,line width=1.4pt] (0,-\r) circle[radius=0.02];
	\draw[color=red,line width=1.4pt] (0,\r) circle[radius=0.02];
\end{scope}

\begin{scope}
	\clip (-1.1,-1.1) rectangle (0,1.1);
	\draw[color=blue,line width=1.4pt] (91:\r) arc (91:269:\r);
	\draw[color=blue,line width=1.4pt] (0,-\r) circle[radius=0.02];
	\draw[color=blue,line width=1.4pt] (0,\r) circle[radius=0.02];
\end{scope}

\xdef\r{0.98}

\begin{scope} 
	\clip (-1.1,0) rectangle (1.1,1.1);
	\draw[color=darkgreen,line width=1.4pt] (1:\r) arc (1:179:\r);
	\draw[color=darkgreen,line width=1.4pt] (\r,0) circle[radius=0.02];
	\draw[color=darkgreen,line width=1.4pt] (-\r,0) circle[radius=0.02];
\end{scope}

\begin{scope} 
	\clip (-1.1,-1.1) rectangle (1.1,0);
	\draw[color=orange,line width=1.4pt] (181:\r) arc (181:359:\r);
	\draw[color=orange,line width=1.4pt] (\r,0) circle[radius=0.02];
	\draw[color=orange,line width=1.4pt] (-\r,0) circle[radius=0.02];
\end{scope}

\begin{scope}[yshift=1.5cm]
	\draw[->] (-1.1,0) -- (1.15,0) coordinate[label={$\mathbb{R}$}];
	\begin{scope}
		\clip (-1,-0.1) rectangle (1,0.1);
		\draw[color=darkgreen,line width=1.4pt] (-0.98,0) -- (0.98,0);
		\draw[color=darkgreen,line width=1.4pt] (-1,0)
			circle[radius=0.02];
		\draw[color=darkgreen,line width=1.4pt] (1,0)
			circle[radius=0.02];
	\end{scope}
\end{scope}

\begin{scope}[yshift=-1.5cm]
	\draw[->] (-1.1,0) -- (1.15,0) coordinate[label={below:$\mathbb{R}$}];
	\begin{scope}
		\clip (-1,-0.1) rectangle (1,0.1);
		\draw[color=orange,line width=1.4pt] (-0.98,0) -- (0.98,0);
		\draw[color=orange,line width=1.4pt] (-1,0) circle[radius=0.02];
		\draw[color=orange,line width=1.4pt] (1,0) circle[radius=0.02];
	\end{scope}
\end{scope}

\begin{scope}[xshift=1.5cm]
	\draw[->] (0,-1.1) -- (0,1.15) coordinate[label={right:$\mathbb{R}$}];
	\begin{scope}
		\clip (-0.1,-1) rectangle (0.1,1);
		\draw[color=red,line width=1.4pt] (0,-0.98) -- (0,0.98);
		\draw[color=red,line width=1.4pt] (0,-1) circle[radius=0.02];
		\draw[color=red,line width=1.4pt] (0,1) circle[radius=0.02];
	\end{scope}
\end{scope}

\begin{scope}[xshift=-1.5cm]
	\draw[->] (0,-1.1) -- (0,1.15) coordinate[label={left:$\mathbb{R}$}];
	\begin{scope}
		\clip (-0.1,-1) rectangle (0.1,1);
		\draw[color=blue,line width=1.4pt] (0,-0.98) -- (0,0.98);
		\draw[color=blue,line width=1.4pt] (0,-1) circle[radius=0.02];
		\draw[color=blue,line width=1.4pt] (0,1) circle[radius=0.02];
	\end{scope}
\end{scope}

\node[color=red] at (23:1) [right] {$U_{x>0}$};
\node[color=red] at (1.25,0) [right] {$\varphi_1$};

\node[color=blue] at (157:1) [left] {$U_{x<0}$};
\node[color=blue] at (-1.25,0) [left] {$\varphi_2$};

\node[color=darkgreen] at (115:1) [below right] {$U_{y>0}$};
\node[color=darkgreen] at (0,1.25) [above] {$\varphi_3$};

\node[color=orange] at (-115:1) [above right] {$U_{y<0}$};
\node[color=orange] at (0,-1.25) [below] {$\varphi_4$};

\draw[->] (-1.1,0) -- (1.15,0) coordinate[label={$x$}];
\draw[->] (0,-1.1) -- (0,1.15) coordinate[label={right:$y$}];

\end{tikzpicture}
\end{document}

