This is a very late answer and the tools used in it were, if I am not mistaken, not available at the time you asked the question. I found this question with this query, and the purpose of this answer is just to mention that now rather convenient means to do what you suggest. The new tool is the pgfplots library fillbetween that allows you to split paths in segments, which you can redraw, fill, or use in other ways.
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc,shapes.multipart,fit,shapes,calc,backgrounds,decorations.pathreplacing,decorations.markings,intersections}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}[scale=2]
\path[name path=t] (1,0) to[out=90,in=180] (2,1) to[out=0,in=90] (3,0); % top arc
\path [name path=ml] (2,0) -- (1,1);
\path [name intersections={of=ml and t}];
\coordinate (A) at (intersection-1);
\path [name path=l] (2,0) -- (3,1);
\path [name intersections={of=l and t}];
\coordinate (B) at (intersection-1);
\draw[thick,draw=blue,] (3,0) to[out=90,in=315] node[midway,above right] {$c$} (B) to[out=135,in=45] node[midway,above] {$b$} (A) to[out=225,in=90] node[midway,above left] {$a$} (1,0);
\draw[thick,draw=blue,] (1,0) -- (0,0) node[midway,above] {};
\draw[thick,draw=blue,] (1,0) to[out=-90,in=180] node[midway,below left] {} (2,-1);
\draw[thick,draw=blue,] (2,-1) to[out=0,in=-90] node[midway,below right] {} (3,0);
\draw[thick,draw=blue,] (4,0) -- (3,0) node[midway,above] {};
\draw[thick,draw=blue,] (2,0) -- node[midway,right] {} (2,-1);
\draw[thick,draw=blue,] (A) -- node[midway,below left] {} (2,0);
\draw[thick,draw=blue,] (2,0) -- node[midway,below right] {} (B);
% draw the left segment
\draw[thick,red,
intersection segments={of=t and ml,sequence={L1}}];
% construct an auxiliary path
\path[name path=aux,%draw=green,thick,
intersection segments={of=t and ml,sequence={L0}}];
% draw the middle segment
\draw[thick,green!60!black,
intersection segments={of=aux and l,sequence={L1}}];
% draw the right segment
\draw[thick,purple,
intersection segments={of=aux and l,sequence={L0}}];
\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
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 L
eft argument in red 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 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}
Best Answer
Update (2011-05-15): I've just tested this with PGF2.10 and it appears that relative coordinates are now supported (again). So if you are able to upgrade to 2.10, the following hacks are unnecessary.
That is annoying!
If you're just drawing straight lines then you can replace the
to
by--
and it will work. However, that won't fix more generalto
paths. If you have a lot ofto
paths that are essentially the same, you can specify your own variant which takes relative coordinates. For example, to get the example that you gave to work (I've added in nodes to show that they work as expected), you could do:To define this globally, you can use the
\tikzstyle
command:To see how to modify the other types of
to
path, you need to look in the filetikzlibrarytopath.code.tex
(usingzsh
:less $(kpsewhich tikzlibrarytopath.code.tex)
). Some of the definitions look easy to modify (simply add a+
in the right place), but some might be a little more complicated as the target coordinate might be used in more than one place. If there's a specific type that you want to get working and you can't figure it out just ask!