如何获得标记箭头指向曲线上装饰点切线的方向
How to get the direction of a marking arrow point to the tangent of decoration point on the curve
我需要装饰一条曲线,使箭头的中心位于曲线的中心。在 tikz
中,这可以通过将 pre length
的值设置为等于箭头的长度来实现,如下例
\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);
但是,现在箭头的方向是箭头所在点的切线,不对称,一点也不好看。
是否可以让箭头的方向与装饰点的切线(pos=0.5
此处)相同,同时保持箭头的中心在同一位置,使图片看起来对称?下图是我需要的。
这个呢?
\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);
对我来说,将曲线分成两部分并在第一条曲线的末端放置一个常规箭头是最好的主意。
受到 Jake's answer of getting the local coordinate system of an arbitrary point of a curve through markings 的启发,我对此进行了调整。
\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);}
给我下图
我需要装饰一条曲线,使箭头的中心位于曲线的中心。在 tikz
中,这可以通过将 pre length
的值设置为等于箭头的长度来实现,如下例
\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);
但是,现在箭头的方向是箭头所在点的切线,不对称,一点也不好看。
是否可以让箭头的方向与装饰点的切线(pos=0.5
此处)相同,同时保持箭头的中心在同一位置,使图片看起来对称?下图是我需要的。
这个呢?
\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);
对我来说,将曲线分成两部分并在第一条曲线的末端放置一个常规箭头是最好的主意。
受到 Jake's answer of getting the local coordinate system of an arbitrary point of a curve through markings 的启发,我对此进行了调整。
\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);}
给我下图