# How to color the area between two three arcs?

I am on my first Tikz attempts and I am trying to figure out a way to color the are between P_{\bot} and Q_{\bot}. What I tried was labeling the intersection such that I could color the area separately, but (see picture) this is not what I want.

Does enyone has an Idea? Here is the code I have till now:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning,intersections,quotes,angles}

\begin{document}
\begin{tikzpicture}
\shade[ball color = gray!40, opacity = 0.2] (0,0) circle (\r);
\draw (0,0) circle (\r);
\draw[blue, thick,name path=p] (-2,0) arc (180:360:2 and 0.6);
\draw[blue,thick,dashed,name path=p'] (2,0) arc (0:180:2 and 0.6);
\draw[dashed,blue] (0,2) coordinate (P) -- (0,0) coordinate (O) -- (2,0)
coordinate (P')
pic["$\cdot$",draw,solid] {angle=P'--O--P};
\fill[black] (O) circle (1pt);
\node (P') [pin={[pin edge={blue},blue]0:$P_{\bot}$}] at (P') {};
\draw[red, very thick] (P) arc (90:130:2) coordinate (Q) node [pos=0.5, above, red, ] {$\gamma$};
\fill[blue] (P) circle (2pt) node [above, blue] {$P$};
\draw[dashed,blue] (Q) -- (O);
\draw (Q) arc (130:220:2) coordinate (Q') ;
\fill [blue] (Q) circle (2pt) node [above left, blue] {Q};
\draw[dashed,blue] (Q') -- (O) ;
\node (Q') [pin={[pin edge={blue},blue]180:$Q_{\bot}$}] at (Q') {};
\pic["$\cdot$",draw,solid, blue] {angle=Q--O--Q'};
\draw[rotate around={40:(0,0)},blue,thick,name path=q] (-2,0) arc (180:360:2
and 0.6) coordinate (Q'');
\draw[rotate around={40:(0,0)},blue,thick,dashed,name path=q'] (2,0) arc
(0:180:2 and 0.6);
\draw[name path=a] (-2,0) arc (180:220:2);
\path[name intersections={of=a and p, by={ap}}];
\path[name intersections={of=a and q, by={aq}}];
\path[name intersections={of=p and q, by={pq}}] ;
\path[name intersections={of=p' and q', by={p'q'}}];
\fill[red, opacity=0.5] (ap) -- (pq) -- (aq)--cycle;
\end{tikzpicture}
\end{document}


The fillbetween library can help here.

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.15}

\usetikzlibrary{shapes,positioning,intersections,quotes,angles}

\begin{document}
\begin{tikzpicture}
\shade[ball color = gray!40, opacity = 0.2] (0,0) circle (\r);
\draw (0,0) circle (\r);
\draw[blue, thick,name path=p] (-2,0) arc (180:360:2 and 0.6);
\draw[blue,thick,dashed,name path=p'] (2,0) arc (0:180:2 and 0.6);
\draw[dashed,blue] (0,2) coordinate (P) -- (0,0) coordinate (O) -- (2,0)
coordinate (P')
pic["$\cdot$",draw,solid] {angle=P'--O--P};
\fill[black] (O) circle (1pt);
\node (P') [pin={[pin edge={blue},blue]0:$P_{\bot}$}] at (P') {};
\draw[red, very thick] (P) arc (90:130:2) coordinate (Q) node [pos=0.5, above, red, ] {$\gamma$};
\fill[blue] (P) circle (2pt) node [above, blue] {$P$};
\draw[dashed,blue] (Q) -- (O);
\draw (Q) arc (130:220:2) coordinate (Q') ;
\fill [blue] (Q) circle (2pt) node [above left, blue] {Q};
\draw[dashed,blue] (Q') -- (O) ;
\node (Q') [pin={[pin edge={blue},blue]180:$Q_{\bot}$}] at (Q') {};
\pic["$\cdot$",draw,solid, blue] {angle=Q--O--Q'};
\draw[rotate around={40:(0,0)},blue,thick,name path=q] (-2,0) arc (180:360:2
and 0.6) coordinate (Q'');
\draw[rotate around={40:(0,0)},blue,thick,dashed,name path=q'] (2,0) arc
(0:180:2 and 0.6);
\draw[name path=a] (-2,0) arc (180:220:2);
\fill [intersection segments={
of=p and q,
sequence={L1 -- R1[reverse]}},
red, opacity=0.5
];
\fill [intersection segments={
of=a and q,
sequence={L1 -- R1}},
red, opacity=0.5
];
\path[name intersections={of=a and p, by={ap}}];
\path[name intersections={of=a and q, by={aq}}];
\path[name intersections={of=p and q, by={pq}}] ;
\path[name intersections={of=p' and q', by={p'q'}}];
\end{tikzpicture}
\end{document}


EXPLANATION: When one does the fill between for intersecting paths, the paths get decomposed in to segments. The first path can be referred to as L or A and the second as R or B. In your case, there is only one intersection, so L1 and and R1 in the first statement are the parts of the upper and lower grand circle left of the intersection, and one has to run the lower path in reverse direction, of course. Note that it is possible to shuffle everything in to one fill command:

\fill [intersection segments={
of=p and q,
sequence={L1 -- R1[reverse]}},
red, opacity=0.5
] (220:2) arc (220:180:2);


It is a matter of taste which of those one feels more comfortable with.

• Awesome! thank you very much for your help and explanation, now everything is clear ! – Sandra May 4 '18 at 14:30