How to get the direction of the arrow marking on the tangent of a decoration point on a curve

I need to decorate the curve with the center of the arrow in the center of the curve. In tikzthis can be achieved by setting the value pre lengthequal 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 the arrow is the tangent of the point at which the tip of the arrow, which is not symmetrical and generally not good. enter image description here

Is it possible for the direction of the arrow to be the same as the tangent of the decoration point ( pos=0.5here), keeping the center of the arrow in the same position so that the image looks symmetrical? The next picture is what I need.enter image description here

+4
source share
2 answers

, .

\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;
}

, \appendarrow{arrow size}{arrow color}{path}. , \appendarrow{6pt}{black}{(-0.5, 0.125) to [out=60, in=120] (0.5, 0.125);} enter image description here

+2

?

\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);

- .

+1

Source: https://habr.com/ru/post/1657314/


All Articles