4

I need to decorate a curve with the center of the arrow at the center of the curve. In tikz this can be achieved by setting the value of pre length equal to the length of the arrow, as in the following example

\draw[decoration={ pre length=8pt, markings, mark=at position 0.5 with {\arrow{Stealth[black,length=8pt]}}}, postaction={decorate}] (-0.5, 0.125) to [out=60, in=120] (0.5, 0.125);

However, now the direction of arrow is the tangent of the point where the arrow tip is, which is not symmetric and not nice at all. enter image description here

Is it possible to get the direction of the arrow the same as the tangent of decoration point (pos=0.5 here) while keeping the center of the arrow at the same position so that the picture looks symmetric ? The following picture is what I need. enter image description here

Kevin Powell
  • 591
  • 1
  • 5
  • 20

2 Answers2

3

Inspired by Jake's answer of getting the local coordinate system of an arbitrary point of a curve through markings, I tweak this out.

\newcommand{\appendarrow}[3]{
\tikzset{
    middlearrow/.style args={#1}{
        decoration={
            markings,
            mark= at position 0.5 with
                {
                    \coordinate (exy1) at (#1/-6.0,0pt);
                    \coordinate (exy2) at (-0.5*#1,#1/3.0);  % 3.0 adjustable 
                    \coordinate (exy3) at (0.5*#1,0pt);
                    \coordinate (exy4) at (-0.5*#1,#1/-3.0); % 3.0 adjustable 
                },
        },
        postaction=decorate
    },
    middlearrow/.default= 3pt
}
\draw[middlearrow=#1] #3;
\fill[#2] (exy1) -- (exy2) -- (exy3) -- (exy4) -- cycle;
}

If we want to draw a path with a middle arrow, just use \appendarrow{arrow size}{arrow color}{path}. For example, \appendarrow{6pt}{black}{(-0.5, 0.125) to [out=60, in=120] (0.5, 0.125);} gives me the following figure enter image description here

Kevin Powell
  • 591
  • 1
  • 5
  • 20
1

What about this?

\draw[thick, ->] (-0.5, 0.125) to [out=90, in=180] (0, 0.5);
\draw[thick] (0, 0.5) to [out=0, in=90] (0.5, 0.125);

To me, cutting the curve in two parts and putting a regular arrow at the end of the first curve is the best idea.

Cyril
  • 3,048
  • 4
  • 26
  • 29
  • Thanks for the suggestion! However, the problem with this approach is that: first, not every path cut be easily divided into two part; second, the center of the arrow is not at the center of the path. I think I worked this out after some effort. See answer below. – Kevin Powell May 05 '17 at 17:58