I have a path in my application that I want to split up in smaller paths. These, I would like to draw with a label attached to them. Take the following image as an example:
The upper arc is split up into three segments by the horizontal lines and by the two lines coming out of the center of the circle. I draw all three parts of the path and attach a label to them.
Now, the way I do this now is a bit tedious. For each segment I have to reconstruct the path by hand: I have to specify how the path is continued at each intersection. In this case the intersection is simple and the continuation is clear, but if the path is complicated this becomes more difficult.
What I would like to do is the following:
- Define a full path, in this case the upper arc from the the left all the way to the right. This path could be arbitrarily complicated.
- Find coordinates in the path by intersecting with other paths.
- Have a command to say: draw the path from the first intersection coordinate to the second and assign a label to this segment. Draw the path from the second intersection to the third, etc.
How can I achieve this?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.multipart,fit,shapes,calc,backgrounds,decorations.pathreplacing,decorations.markings,intersections}
\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);
\end{tikzpicture}
\end{document}
standalone
document class instead ofminimal
. See tex.stackexchange.com/questions/42114/…pos=...
and the answer provides and iterative solution.\draw
in pieces that would really depend on exactly how you want to specify the path -- for instance, you could code each portion of the path separately viacontrol
points.