8

I have three intersecting arcs, and I want to fill the region inside the intersection points.

\documentclass{article}
\usepackage{tikz}
\begin{document}
    \begin{figure}[htbp]
        \centering
        \begin{tikzpicture}[scale=3]
        \tikzstyle{intersection} = [draw, circle ,fill=darkgray, inner sep=0.4mm]
        \draw (0.95572,-0.29428)  arc (-19.41:18.41:1);
        \draw (0.9414, 0.33728) arc (226:254:1.5);
        \draw (1.58918, 0.04265) arc (102:122:2);
        \end{tikzpicture}
    \end{figure}
\end{document}

What I want is something like this:

enter image description here

But when I use

\fill (0.95572,-0.29428)  arc (-19.41:18.41:1) (0.9414, 0.33728) arc (226:254:1.5) (1.58918, 0.04265) arc (102:122:2);

I get this:

enter image description here

The arcs are filled through the center of the arc, but I want the complement of this. How can I do it?

I can use a "hack" by filling in the triangle defined by the intersection points, and then filling the arcs white to achieve my goal, but I am highly suspicious that this is a generic solutiuon.

5

This is the first step: add --. The second step is to clip. This yields

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
    \begin{figure}[htbp]
        \centering
        \begin{tikzpicture}[scale=3]
        \tikzstyle{intersection} = [draw, circle ,fill=darkgray, inner sep=0.4mm]
        \draw[name path=path1] (0.95572,-0.29428)  arc (-19.41:18.41:1);
        \draw[name path=path2] (0.9414, 0.33728) arc (226:254:1.5);
        \draw[name path=path3] (1.58918, 0.04265) arc (102:122:2);
        \path[name intersections={of=path1 and path2,by=x12}];
        \path[name intersections={of=path2 and path3,by=x23}];
        \path[name intersections={of=path3 and path1,by=x31}];
        \begin{scope}
        \clip (x12)--(x23)--(x31)--cycle;
        \filldraw[draw=black,fill=blue] (0.95572,-0.29428)  arc (-19.41:18.41:1) -- (0.9414, 0.33728) arc
        (226:254:1.5)-- (1.58918, 0.04265) arc (102:122:2);
        \end{scope}
     \end{tikzpicture}
    \end{figure}
\end{document}

enter image description here

EDIT: I only made the code a bit shorter and changed the fill color, otherwise this is the original code.

  • In which order shall I write the arcs? – padawan Feb 27 '18 at 17:03
  • It is OK, but did you use that ordering according to some rule, or just arbitrarily? – padawan Feb 27 '18 at 17:08
  • I now understood. I have to start drawing the next arc where the previous one is finished. Otherwise, TikZ closes the arc from inside, as you have mentioned. Thanks! – padawan Feb 27 '18 at 17:22
  • @padawan Yes. I could not have explained this better ;-) – marmot Feb 27 '18 at 17:26
6

enter image description here

with help of backgrounds and intersections libraries:

\documentclass[tikz, margin=3mm]{standalone}%{article}
%\usepackage{tikz}
\usetikzlibrary{backgrounds, intersections}

\begin{document}
%    \begin{figure}[htbp]
%        \centering
    \begin{tikzpicture}[scale=3]
% fill arcs and determine their names
\fill[white, name path=a]   (0.95572,-0.29428)  arc (-19.41:18.41:1);
\fill[white, name path=b]   (0.9414, 0.33728)   arc (226:254:1.5);
\fill[white, name path=c]   (1.58918, 0.04265)  arc (102:122:2);
% calculate intersections
\path[name intersections={of=a and b, by={ab}}] ;
\path[name intersections={of=a and c, by={ac}}] ;
\path[name intersections={of=b and c, by={bc}}] ;
% background fill
\scoped[on background layer]\fill[red] (ab) -- (ac) -- (bc) -- cycle; % color determine according to your wish
% drawing arcs agaib
\draw   (0.95572,-0.29428)  arc (-19.41:18.41:1);
\draw   (0.9414, 0.33728)   arc (226:254:1.5);
\draw   (1.58918, 0.04265) arc (102:122:2);
    \end{tikzpicture}
%    \end{figure}
\end{document}

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.