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}
Best Answer
A solution which allows to draw
intersection segments
of any two intersections is available as tikz libraryfillbetween
.This library works as general purpose
tikz
library, but it is shipped withpgfplots
and you need to loadpgfplots
in order to make it work:The key
intersection segments
is described in all detail in thepgfplots
reference manual section "5.6.6 Intersection Segment Recombination"; the key idea in this case is tocreate a temporary path
temp1
which is the first intersection segment ofred and blue
, more precisely, it is the first intersection segment in theL
eft argument inred and blue
:red
. This path is drawn as thin black path. Substitute its\draw
statement by\path
to make it invisible.Compute the desired
intersection segment
by intersectingtemp1
andgreen
and use the correct intersection segment. By trial and error I figured that it is the third segment of pathtemp1
which is written asL3
(L
= left argument intemp1 and green
and3
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: