# [Tex/LaTex] TikZ: Drawing an arc from an intersection to an intersection

tikz-pgf

I want to draw an arc with a given radius from the point the arc intersects with a given circle to the point where the arc intersects with another circle. I have been reading through a lot of the TikZ manual, but to no avail.
Can anyone help?

This PDF (http://www.mycroft.ch/tikztest.pdf) (MWE below) is intended to illustrate the problem. There are four circles, a part of each I want to use as path. The resulting curved wedge is then to be filled in black.

The green arc is no problem, I have start angle and end angle for it.
For the two orange arcs I only have one angle (the one near the red circle is just an estimate).
For the red arc I have nothing (both ends are estimates, thought to illustrate).

Interestingly, I can calculate the intersections (marked by the red circles), but I cannot fathom how to draw an arc there.

Hopefully I am overlooking something incredibly obvious! Thanks.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{intersections,scopes}
\tikzset{
pics/carc/.style args={#1:#2:#3}{
code={
\draw[pic actions] (#1:#3) arc(#1:#2:#3);
}
}
}

\begin{document}
\begin{tikzpicture}

\draw [name path=three] (120:1.06) circle (1.9);
\draw [name path=four] (0:1.06) circle (2.12);
\draw [name path=five] (0:0.77) circle (2.41);
\draw [name path=two] (0:0) circle (1.06);

\draw[green, thick] (0:3.18) arc [radius=2.12, start angle=0, end angle=180];
\draw[orange, thick] (0:3.18) arc [radius=2.41, start angle=0, end angle=197];
\draw[orange, thick] (180:1.06) arc [radius=1.06, start angle=180, end angle=245];
\draw[red, thick, name intersections={of=five and three}] (intersection-2) circle (2pt) node {};
\draw[red, thick, name intersections={of=two and three}] (intersection-1) circle (2pt) node {};

{ [xshift=-0.53cm,yshift=0.918cm] \pic [red,thick] {carc=238:274:1.9}; }

\end{tikzpicture}

\end{document}


A solution which allows to draw intersection segments of any two intersections is available as tikz library fillbetween.

This library works as general purpose tikz library, but it is shipped with pgfplots and you need to load pgfplots in order to make it work:

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{fillbetween}

\begin{document}

\begin{tikzpicture}

\draw [name path=red,red] (120:1.06) circle (1.9);
%\draw [name path=yellow,yellow] (0:1.06) circle (2.12);
\draw [name path=green,green!50!black] (0:0.77) circle (2.41);
\draw [name path=blue,blue] (0:0) circle (1.06);

% substitute this temp path by \path to make it invisible:
\draw[name path=temp1, intersection segments={of=red and blue,sequence=L1}];
\draw[red,-stealth,ultra thick, intersection segments={of=temp1 and green,sequence=L3}];

\end{tikzpicture}

\end{document}


The key intersection segments is described in all detail in the pgfplots reference manual section "5.6.6 Intersection Segment Recombination"; the key idea in this case is to

1. create a temporary path temp1 which is the first intersection segment of red and blue, more precisely, it is the first intersection segment in the Left argument in red and blue : red. This path is drawn as thin black path. Substitute its \draw statement by \path to make it invisible.

2. Compute the desired intersection segment by intersecting temp1 and green and use the correct intersection segment. By trial and error I figured that it is the third segment of path temp1 which is written as L3 (L = left argument in temp1 and green and 3 means third segment of that path).

The argument involves some trial and error because fillbetween is unaware of the fact that end and startpoint are connected -- and we as end users do not see start and end point.

Note that you can connect these path segments with other paths. If such an intersection segment should be the continuation of another path, use -- as before the first argument in sequence. This allows to fill paths segments:

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{fillbetween}

\begin{document}

\begin{tikzpicture}

\draw [name path=red,red] (120:1.06) circle (1.9);
%\draw [name path=yellow,yellow] (0:1.06) circle (2.12);
\draw [name path=green,green!50!black] (0:0.77) circle (2.41);
\draw [name path=blue,blue] (0:0) circle (1.06);

% substitute this temp path by \path to make it invisible:
\draw[name path=temp1, intersection segments={of=red and blue,sequence=L1}];
\draw[red,fill=blue,-stealth,ultra thick, intersection segments={of=temp1 and green,sequence=L3}]
[intersection segments={of=temp1 and green, sequence={--R2}}]
;

\end{tikzpicture}

\end{document}