5

I have this image: enter image description here

That is made with this code:

     \documentclass{article}
     \usepackage{tikz}
\usepackage{amssymb,amsthm,amsmath}
\usetikzlibrary{shapes,positioning,intersections,quotes}

\begin{document}

\begin{center}
         \begin{tikzpicture}
         \draw [rotate=270] (0,0)  arc (180:0:1);
         \draw [rotate=270] (-2,0)  arc (180:0:1);
         \draw (0,0) circle (2cm);
         \draw[dashed] (0,2.5) -- (0,-2.5);
         \draw[dashed](-2.5,0) -- (2.5,0);
         \draw (0,0) -- (-1.1547,1.9);
         \draw (0,0) -- (-1.01,2);
         \draw [rotate=120](0,0) -- (-1.1547,1.9);
         \draw [rotate=120](0,0) -- (-1.01,2);
        \filldraw[black] (1.2,0) circle (0pt)
 node[anchor=west] {$S_0$};
        \filldraw[black] (-1.2,0) circle (0pt)
  node[anchor=west] {$S_3$};
        \filldraw[black] (0,1.2) circle (0pt)
  node[anchor=west] {$S_1$};
        \filldraw[black] (0,-1.2) circle (0pt)
  node[anchor=west] {$S_2$};

        \filldraw[black] (-1,2.1) circle (0pt)
  node[anchor=west] {\tiny{$R_1$}};
         \end{tikzpicture}
\end{center}




\end{document}

And I want to know if there is a way to color in gray the zone that is between the 2 lines (in both zones). Any ideas? Thanks.

6

Sure. (But why do you not use polar coordinates?)

\documentclass{article}
\usepackage{tikz}
\begin{document}
\section*{Two methods that do not require libraries}
\subsection*{Method 1: clip}
\begin{center}
  \begin{tikzpicture}
         \draw [rotate=270] (0,0)  arc (180:0:1);
         \draw [rotate=270] (-2,0)  arc (180:0:1);
         \draw (0,0) circle (2cm);
         \draw[dashed] (0,2.5) -- (0,-2.5);
         \draw[dashed](-2.5,0) -- (2.5,0);
         \draw (0,0) -- (-1.1547,1.9);
         \draw (0,0) -- (-1.01,2);
         \draw [rotate=120](0,0) -- (-1.1547,1.9);
         \draw [rotate=120](0,0) -- (-1.01,2);
         \path (1.2,0)  node[anchor=west] {$S_0$};
         \path (-1.2,0)   node[anchor=west] {$S_3$};
         \path (0,1.2)   node[anchor=west] {$S_1$};
         \path (0,-1.2)   node[anchor=west] {$S_2$};
         \path (-1,2.1)   node[anchor=west] {\tiny{$R_1$}};
         \clip (0,0) circle[radius=2cm-\pgflinewidth/2];
         \draw[fill=gray] (0,0) -- (-1.01,2) -- (-1.1547,1.9);
         \draw[fill=gray,rotate=120] (0,0) -- (-1.01,2) -- (-1.1547,1.9);
  \end{tikzpicture}
\end{center}
\subsection*{Method 2: compute the polar coordinates of the points and use them}
\begin{center}
 \begin{tikzpicture}
         \draw [rotate=270] (0,0)  arc (180:0:1);
         \draw [rotate=270] (-2,0)  arc (180:0:1);
         \draw (0,0) circle (2cm);
         \draw[dashed] (0,2.5) -- (0,-2.5);
         \draw[dashed](-2.5,0) -- (2.5,0);
         \draw (0,0) -- (-1.1547,1.9);
         \draw (0,0) -- (-1.01,2);
         \pgfmathsetmacro{\myangleOne}{atan2(1.9,-1.1547)}
         %\pgfmathsetmacro{\myradius}{veclen(1.9,-1.1547)}
         \pgfmathsetmacro{\myangleTwo}{atan2(2,-1.01)}
         \draw[fill=gray] (0,0) -- (\myangleOne:2) arc(\myangleOne:\myangleTwo:2)
         --cycle;
         %\typeout{\myangleOne,\myangleTwo}
         \draw [rotate=120](0,0) -- (-1.1547,1.9);
         \draw [rotate=120](0,0) -- (-1.01,2);
         \draw[fill=gray,rotate=120] (0,0) -- (\myangleOne:2) arc(\myangleOne:\myangleTwo:2)
         --cycle;
        \path (1.2,0)  node[anchor=west] {$S_0$};
        \path (-1.2,0)   node[anchor=west] {$S_3$};
        \path (0,1.2)   node[anchor=west] {$S_1$};
        \path (0,-1.2)   node[anchor=west] {$S_2$};
        \path (-1,2.1)  node[anchor=west] {\tiny{$R_1$}};
 \end{tikzpicture}
\end{center}
\end{document}

enter image description here

  • Wow, thanks, actually I don't use the polar plots becouse I am just learning to use Tikz. But I will look for it. – J.Rodriguez Mar 26 at 2:43
  • @J.Rodriguez In this situation they may be very useful. Anyway, I added a second method (clip) in case you do not want to use them. – marmot Mar 26 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.