1

I need to fill a zone defined by 4 arcs for which I know there centers and radius.

I didn't manage to create the contour of this area and fill it.

Here is my MWE with circle but the size of the picture is too large:

\documentclass[tikz,border=5]{standalone}
\usepackage{amsmath}
\usepackage{pgfplots}

\begin{document} \begin{tikzpicture} \def\RI{1}; \def\RE{6}; \def\RL{5}; \draw[name path=CI] circle[radius=\RI]; \draw[name path=CE,blue] (0,0) circle [radius=\RE]; \draw[name path=CR,green] (0,\RI+\RL) circle[radius=\RL]; \draw[name path=CL,red] (0,-\RI-\RL) circle[radius=\RL]; \node[purple] at (-\RI/2-\RE/2,0) {\tiny Color here}; \path[purple,ultra thick,intersection segments={of=CR and CE,sequence={L2[reverse]--R3}},name path=P1,->,dashed]; \path[purple,ultra thick,intersection segments={of=P1 and CL,sequence={L1--R2[reverse]}},name path=P2,->,dashed]; \fill[purple,ultra thick,intersection segments={of=P2 and CI,sequence={L2--R2[reverse]}},name path=P3,->,dashed]; \end{tikzpicture} \end{document}

producing fill zone build with circle

But when I try to do the same with arc to have smaller output, I cannot manage to build this fill zone.

\begin{tikzpicture}
    \def\RI{1};
    \def\RE{6};
    \def\RL{5};
    \draw[name path=CI] circle[radius=\RI];
    \draw[name path=CE,blue] ++(0,\RE) arc [start angle=90, end angle=270,radius=\RE];
    \draw[name path=CR,green] (-\RL,\RI+\RL) arc [start angle=180, end angle=270,radius=\RL];
    \draw[name path=CL,red] (0,-\RI) arc [start angle=90, end angle=180,radius=\RL];
    \node[purple] at (-\RI/2-\RE/2,0) {\tiny Color here};
    % \path[purple,ultra thick,intersection segments={of=CR and CE,sequence={L2[reverse]--R3}},name path=P1,->,dashed];
    % \path[purple,ultra thick,intersection segments={of=P1 and CL,sequence={L1--R2[reverse]}},name path=P2,->,dashed];
    % \fill[purple,ultra thick,intersection segments={of=P2 and CI,sequence={L2--R2[reverse]}},name path=P3,->,dashed];
\end{tikzpicture}

produce fill zone produced with arc

EDIT 1: Solution using overlay from @Qrrbrbirlbel comment

If I use overlay option on \draw command, the top part seems to be good but not the bottom. I think the problem comes from the intersection segment which has not overlay option but I know know how to set it. My goal is to have the closest look on the fill area.

\begin{tikzpicture}
    \def\RI{1}
    \def\RE{6}
    \def\RL{5}
    \draw[name path=CI] circle[radius=\RI];
    \draw[name path=CE,blue,overlay] (0,0) circle [radius=\RE];
    \draw[name path=CR,green,overlay] (0,\RI+\RL) circle[radius=\RL];
    \draw[name path=CL,red,overlay] (0,-\RI-\RL) circle[radius=\RL];
    \node[purple] at (-\RI/2-\RE/2,0) {\tiny Color here};
    \path[purple,ultra thick,intersection segments={of=CR and CE,sequence={L2[reverse]--R3}},name path=P1,->,dashed,overlay];
    \path[purple,ultra thick,intersection segments={of=P1 and CL,sequence={L1--R2[reverse]}},name path=P2,->,dashed,overlay];
    \fill[purple,ultra thick,intersection segments={of=P2 and CI,sequence={L2--R2[reverse]}},name path=P3,->,dashed];
\end{tikzpicture}

enter image description here

Sigmun
  • 1,121
  • By the way, you can \clip the diagram before drawing everything, very similar to how OP of Q694499 handled this. If you want the circles or arcs to not even change the diagram's size, use overlay with them (and also don't draw them then, of course). – Qrrbrbirlbel Sep 06 '23 at 19:23
  • I don't know in advance the size of the picture because it depend on intersections between circles so I am not sure I can use clip. But overlay, thanks but I cannot manage to make it fully work. See the edit part. – Sigmun Sep 11 '23 at 08:20
  • You have to also overlay P1 and/or P2. They will also contribute to the bounding box, again. But I don't really understand how your final diagram should look like. Just the area? Or some of the circles/arcs? This is obviously important to know for deciding what to clip and/or overlay. – Qrrbrbirlbel Sep 11 '23 at 12:21
  • @Qrrbrbirlbel I've edit my question. The goal is to have the closest look possible to the filled area – Sigmun Sep 12 '23 at 09:08

1 Answers1

4

The sequences need to be changed to

  • P1: L2[reverse]--R2 and
  • P2: L1--R1[reverse]

because you now have different intersections and a different segmentation of the paths. The blue circle (CE) was intersected by the green one (CR) twice but you needed the third segment (R3) but now, you have only one intersection so they are only two segments at total where you need the last one: R2.

The same applies to P2 and the intersections between blue and red. Since green and red are tangent to the black one, no change is necessary for the sequence of P3.

Code

\documentclass[tikz, border=5pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\def\RI{1} \def\RE{6} \def\RL{5} % no ; here
\draw[name path=CI] circle[radius=\RI];
\draw[name path=CE, blue]  (0,\RE)
  arc [start angle= 90, end angle=270, radius=\RE];
\draw[name path=CR, green] (-\RL,\RI+\RL)
  arc [start angle=180, end angle=270, radius=\RL];
\draw[name path=CL, red] (0,-\RI)
  arc [start angle= 90, end angle=180, radius=\RL];
\path[name path=P1,
  intersection segments={of=CR and CE, sequence={L2[reverse]--R2}}];
\path[name path=P2,
  intersection segments={of=P1 and CL, sequence={L1--R1[reverse]}}];
\fill[purple, name path=P3, % naming not really necessary
  intersection segments={of=P2 and CI, sequence={L2--R2[reverse]}}];
\end{tikzpicture}
\end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821