Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have seen a lot of questions asking about how to draw arrows along curves. The decoration libary can help with this, but the solution seems very manual.. Is it possible to make a command that draws an arc, and places two arows on the arc?

If one calls S1 the start of the arc, S4 the end. And the placement of S2, and S3 for the points where the arows are placed. Then the arclength between S1 and S2, S2 and S3, S3 and S4 should be equal. Eg the placement of the arrows should always be equally spaced along the arc.

I gave this problem a go using a mix between tikz, and euclide. But any solutions is fine.

\documentclass[12pt,a4paper]{standalone}
\usepackage{tikz,tkz-euclide,pgfplots}
\usetikzlibrary{decorations.markings}
\usetkzobj{all}
\newcommand{\tkzkonturS}[5]{%
    \draw[domain=#4:#5,smooth,style={postaction={decorate},decoration={markings,mark=at position 0.33 with {\arrow{stealth}}},
           decoration={markings,mark=at position 0.66 with {\arrow{stealth}}}}
        ]
        plot ({#1+#3*cos(\x)}, {#1+#3*sin(\x)});
}
\newcommand{\tkzkonturR}[5]{%
    \draw[domain=#4:#5,smooth,style={postaction={decorate},decoration={markings,mark=at position 0.33 with {\arrow{stealth reversed}}},
           decoration={markings,mark=at position 0.66 with {\arrow{stealth reversed}}}}
        ]
        plot ({#1+#3*cos(\x)}, {#1+#3*sin(\x)});
}
\begin{document}

    \begin{tikzpicture}
        \def\radius{2} \def\radiuss{0.5}
        \pgfmathsetmacro{\k}{1.2*\radius}

        \pgfmathsetmacro{\P1}{0.70710*\radiuss}
        \pgfmathsetmacro{\P2}{1.2*\radiuss}

        \tkzDefPoint(0,0){S1} 
        \tkzDefPoint(0.4,0){S11} 
        \tkzDefPoint(\radius,0){A}
        \tkzDefPoint(1,0){S2}
        \tkzDefPoint(1.4,0){S22}

        \tkzDefPoint(-\k,0){x1}
        \tkzDefPoint(\k,0){x2}
        \tkzDefPoint(0,-\k){y1}
        \tkzDefPoint(0,\k){y2}
        \tkzDrawSegments[thick,-stealth](x1,x2 y1,y2)

        \tkzkonturS{0}{0}{2}{0}{360}
        \tkzkonturR{0}{0}{1}{0}{360}
        \tkzkonturR{1}{0}{1.5}{0}{360}

        \tkzDrawPoints[color=red,shape=cross out,size=10pt](S1,S2)
        \tkzLabelPoint[above right](x2){$x$}
        \tkzLabelPoint[right](y2){$y$}
    \end{tikzpicture}   
\end{document}

The problem with my code is that I often run into dimensions to large, if I use too small of an radius, the arrows are not equally spaced. Also using this approach one needs a seperate command to plot the arrows reversed.

share|improve this question
    
Duplicate ? tex.stackexchange.com/questions/20833/… –  Alain Matthes Feb 4 at 17:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.