3

For this question, I refer to the post connect sides by arrows in any contour, polygonal figure, closed curve, etc. Here is the code modified by me. What I want is to mark each intersection point of the line L with the blue contour vertical lines.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings, calc}
\tikzset{
    marks/.style 2 args={
        postaction=decorate, 
        decoration={
            markings, mark=between positions {1/(#1+1)} and {(#1)/(#1+1)} step {1/(#1+1)} with {
                \coordinate[name=#2\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}];
            }
        }
    },
    midarrow/.style={postaction=decorate, decoration={markings, mark=at position 0.5 with {\arrow{>}}}}
}

\newcommand{\contour}[6][]{% #1=tikz options, #2=num lines, #3=start, #4=end, #5=bottom, #6=top
    \draw[marks={#2}{A}, #1] #3;
    \draw[marks={#2}{B}, #1] #4;
    \draw[marks={4}{C}, midarrow, #1] #5;
    \draw[marks={4}{D}, midarrow, #1] #6;
    \foreach \l in {1,...,#2}{
        \draw[smooth, midarrow, #1] plot coordinates {(A\l)
            ($($(A\l)!{.2}!(B\l)$)!.5!($(C1)!{\l/(#2+1)}!(D1)$)$)
            ($($(A\l)!{.4}!(B\l)$)!.5!($(C2)!{\l/(#2+1)}!(D2)$)$)
            ($($(A\l)!{.6}!(B\l)$)!.5!($(C3)!{\l/(#2+1)}!(D3)$)$)
            ($($(A\l)!{.8}!(B\l)$)!.5!($(C4)!{\l/(#2+1)}!(D4)$)$)
            (B\l)};
    }
}
\usetikzlibrary{intersections}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{decorations.pathmorphing,decorations.markings,intersections}
\usetikzlibrary{intersections,calc}
\tikzset{
    on each segment/.style={
        decorate,
        decoration={
            show path construction,
            moveto code={},
            lineto code={
                \path [#1]
                (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
            },
            curveto code={
                \path [#1] (\tikzinputsegmentfirst)
                .. controls
                (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
                ..
                (\tikzinputsegmentlast);
            },
            closepath code={
                \path [#1]
                (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
            },
        },
    },
}
\makeatother
\begin{document}

\begin{tikzpicture}
\contour[blue, thick,name path =plotA]{8}
    {(0,0) to[bend left] (2,6)}
    {[looseness=2] (4,1) to[out=45, in=225] (5,5)}
    {(0,0) -- (4,1)}
    {(2,6) to[bend right] (5,5)}
     \draw[thick,xshift=0.61cm,name path=plotB,yshift=-4cm,xshift=0.6cm](2.5,4.5) to [out=90,in=-90] ++ (0,5) node[anchor=0]{$L$};
    \fill[blue,name intersections={of=plotB and plotA}]
            (intersection-3) circle[radius=2pt] node[right,yshift=-0.3cm] {$m$};
    
\end{tikzpicture}

\end{document}

I wanted the 3rd intersection point, for instance, and I ve got this: enter image description here

1 Answer 1

5

Instead of trying to name the entire plot, name each curve in the \contour macro. Then you can use intersections to identify the desired point.

Note: I removed much of your code that was unnecessary, for example, you were loading tikz twice, as well as several libraries. The style on each segment is not used.

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings, calc, intersections}
\tikzset{
    marks/.style 2 args={
        postaction=decorate, 
        decoration={
            markings, mark=between positions {1/(#1+1)} and {(#1)/(#1+1)} step {1/(#1+1)} with {
                \coordinate[name=#2\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}];
            }
        }
    },
    midarrow/.style={postaction=decorate, decoration={markings, mark=at position 0.5 with {\arrow{>}}}}
}

\newcommand{\contour}[6][]{% #1=tikz options, #2=num lines, #3=start, #4=end, #5=bottom, #6=top
    \draw[marks={#2}{A}, #1] #3;
    \draw[marks={#2}{B}, #1] #4;
    \draw[marks={4}{C}, midarrow, #1] #5;
    \draw[marks={4}{D}, midarrow, #1] #6;
    \foreach \l in {1,...,#2}{
        \draw[smooth, midarrow, #1, name path=curve\l] plot coordinates {(A\l)
            ($($(A\l)!{.2}!(B\l)$)!.5!($(C1)!{\l/(#2+1)}!(D1)$)$)
            ($($(A\l)!{.4}!(B\l)$)!.5!($(C2)!{\l/(#2+1)}!(D2)$)$)
            ($($(A\l)!{.6}!(B\l)$)!.5!($(C3)!{\l/(#2+1)}!(D3)$)$)
            ($($(A\l)!{.8}!(B\l)$)!.5!($(C4)!{\l/(#2+1)}!(D4)$)$)
            (B\l)};
    }
}

\begin{document}

\begin{tikzpicture}
\contour[blue, thick,name path =plotA]{8}
    {(0,0) to[bend left] (2,6)}
    {[looseness=2] (4,1) to[out=45, in=225] (5,5)}
    {(0,0) -- (4,1)}
    {(2,6) to[bend right] (5,5)}
     \draw[thick, name path=myline](3.7,.5) to [out=90,in=-90] ++ (0,5) node[anchor=0]{$L$};
     \fill[blue, name intersections={of=myline and curve3}]
            (intersection-1) circle[radius=2pt] node[below right]{$m$};   
\end{tikzpicture}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .