重ね合わせた矢印:「ツイン」テールを使用してそれらを区別するにはどうすればよいでしょうか?

重ね合わせた矢印:「ツイン」テールを使用してそれらを区別するにはどうすればよいでしょうか?

2 つのベクトルは同じ方向を向いており、矢印は区別されません。私は、これらを「シャム双生児」のように、つまり、矢印の半分が左向き、もう半分が右向きに見えるようにしたいと考えています。私の言いたいことは、次の画像の左上隅でよりよく説明できます: (1 つの矢印は赤、もう 1 つは黒)。

ロープに沿った求心加速度と牽引力を持つ振り子

の中にマニュアルTill Tantau の「TikZ と pgf」では、これらのスタイルは見つかりませんでした。実際、[o-stealth] を使用しようとしたときに、次のようになりました。

キー「o」が分かりません。

私のコードはごちゃごちゃしていますが、Tikz 初心者なので非常にシンプルです。その一部を以下に示します。

    \documentclass[tikz]{standalone}
    \usepackage[utf8]{inputenc}
    \usepackage{tikz}\begin{document}
    \usetikzlibrary{calc,patterns,angles,quotes}
    \begin{tikzpicture}
    \pgfmathsetmacro{\Gvec}{1} 
    \pgfmathsetmacro{\midAngle}{20}
    \pgfmathsetmacro{\Gcosmid}{\Gvec*cos(\midAngle)}
    \coordinate (center) at (0,0);
    \draw [thin, gray] (center) -- ++(270-\midAngle:2) coordinate (left);
    \draw [thick, -stealth] (left)-- ++(90-\midAngle:\Gcosmid + 0.3) coordinate (Tmid);
    \draw [thin] (left) -- ++(270-\midAngle:-\Gcosmid) coordinate (gcosmid);
    \draw [->, red] (gcosmid) -- (Tmid) node [left] {\footnotesize{$a_{cp}$}};
    \end{tikzpicture}

「シャムの矢」は問題に対処する良い方法だと思います。しかし、他の選択肢も受け入れます。

編集: シャム矢印は主に色の差別化に依存しています。後になって、私は良い形状の組み合わせに賭けました (ベクトルが同じ性質を持つ場合、-ステルスと -angle 90 スタイルの重ね合わせ、例: mg と a_r)。

答え1

ようこそ!こちらは「Siamese Stealth」の矢印の先端です。形状がよくわからなかったので、Stealthベースとして使用しました。pgflibraryarrows.meta.code.tex必要に応じて、 から他の矢印のコードをコピーできます。これを機能させるには、新しい矢印パラメータ、2 番目の色を宣言し、パスを 2 つに分割する必要があります。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta}
\makeatletter
\pgfkeys{/pgf/arrow keys/second color/.code=%
\pgfarrowsaddtooptions{\edef\pgfarrowsecondcolor{#1}}}
\pgfdeclarearrow{
  name = Siamese Stealth,
  defaults = {
    length  = +3pt 4.5 .8,
    width'  = +0pt .75,
    inset'  = +0pt 0.325,
    line width = +0pt 0.5 0.5,
    second color=red
  },
  setup code = {
    % Cap the line width at 1/4th distance from inset to tip
    \pgf@x\pgfarrowlength
    \advance\pgf@x by-\pgfarrowinset
    \[email protected]\pgf@x
    \ifdim\pgf@x<\pgfarrowlinewidth
      \pgfarrowlinewidth\pgf@x
    \fi
    % Compute front miter length:
    \pgfmathdivide@{\pgf@sys@tonumber\pgfarrowlength}{\pgf@sys@tonumber\pgfarrowwidth}%
    \let\pgf@temp@quot\pgfmathresult%
    \pgf@x\pgfmathresult pt%
    \pgf@x\pgfmathresult\pgf@x%
    \pgf@x4\pgf@x%
    \advance\pgf@x by1pt%
    \pgfmathsqrt@{\pgf@sys@tonumber\pgf@x}%
    \pgf@xc\pgfmathresult\pgfarrowlinewidth% xc is front miter
    \[email protected]\pgf@xc
    \pgf@xa\pgf@temp@quot\pgfarrowlinewidth% xa is extra harpoon miter
    % Compute back miter length:
    \[email protected]\pgfarrowwidth%
    \csname pgfmathatan2@\endcsname{\pgfmath@tonumber\pgfarrowlength}{\pgfmath@tonumber\pgf@ya}%
    \pgf@yb\pgfmathresult pt%
    \csname pgfmathatan2@\endcsname{\pgfmath@tonumber\pgfarrowinset}{\pgfmath@tonumber\pgf@ya}%
    \pgf@ya\pgfmathresult pt%
    \advance\pgf@yb by-\pgf@ya%
    \[email protected]\pgf@yb% half angle in yb
    \pgfmathtan@{\pgf@sys@tonumber\pgf@yb}%
    \pgfmathreciprocal@{\pgfmathresult}%
    \pgf@yc\pgfmathresult\pgfarrowlinewidth%
    \[email protected]\pgf@yc%
    \advance\pgf@ya by\pgf@yb%
    \pgfmathsincos@{\pgf@sys@tonumber\pgf@ya}%
    \pgf@ya\pgfmathresulty\pgf@yc% ya is the back miter
    \pgf@yb\pgfmathresultx\pgf@yc% yb is the top miter
    \ifdim\pgfarrowinset=0pt%
      \[email protected]\pgfarrowlinewidth% easy: back miter is half linewidth
    \fi
    % Compute inset miter length:
    \pgfmathdivide@{\pgf@sys@tonumber\pgfarrowinset}{\pgf@sys@tonumber\pgfarrowwidth}%
    \let\pgf@temp@quot\pgfmathresult%
    \pgf@x\pgfmathresult pt%
    \pgf@x\pgfmathresult\pgf@x%
    \pgf@x4\pgf@x%
    \advance\pgf@x by1pt%
    \pgfmathsqrt@{\pgf@sys@tonumber\pgf@x}%
    \pgf@yc\pgfmathresult\pgfarrowlinewidth% yc is inset miter
    \[email protected]\pgf@yc%
    % Inner length (pgfutil@tempdima) is now arrowlength - front miter - back miter
    \pgfutil@tempdima\pgfarrowlength%
    \advance\pgfutil@tempdima by-\pgf@xc%
    \advance\pgfutil@tempdima by-\pgf@ya%
    \[email protected]\pgfarrowwidth%
    \advance\pgfutil@tempdimb by-\pgf@yb%
    % harpoon miter correction
    \ifpgfarrowroundjoin
      \pgfarrowssetbackend{\pgf@ya\advance\pgf@x by-.5\pgfarrowlinewidth}
    \else
      \pgfarrowssetbackend{0pt}
    \fi
    \ifpgfarrowharpoon
      \pgfarrowssetlineend{\pgfarrowinset\advance\pgf@x
        by\pgf@yc\advance\pgf@x by.5\pgfarrowlinewidth}
    \else
      \pgfarrowssetlineend{\pgfarrowinset\advance\pgf@x by\pgf@yc\advance\pgf@x by-.25\pgfarrowlinewidth}
      \ifpgfarrowreversed
        \ifdim\pgfinnerlinewidth>0pt
          \pgfarrowssetlineend{\pgfarrowinset}
        \else
          \pgfarrowssetlineend{\pgfutil@tempdima\advance\pgf@x by\pgf@ya\advance\pgf@x by-.25\pgfarrowlinewidth}
        \fi
      \fi
    \fi
    \ifpgfarrowroundjoin
      \pgfarrowssettipend{\pgfutil@tempdima\advance\pgf@x by\pgf@ya\advance\pgf@x by.5\pgfarrowlinewidth}
    \else
      \pgfarrowssettipend{\pgfarrowlength\ifpgfarrowharpoon\advance\pgf@x by\pgf@xa\fi}
    \fi
    % The hull:
    \pgfarrowshullpoint{\pgfarrowlength\ifpgfarrowroundjoin\else\ifpgfarrowharpoon\advance\pgf@x by\pgf@xa\fi\fi}{\ifpgfarrowharpoon-.5\pgfarrowlinewidth\else0pt\fi}%
    \pgfarrowsupperhullpoint{0pt}{.5\pgfarrowwidth}%
    \pgfarrowshullpoint{\pgfarrowinset}{\ifpgfarrowharpoon-.5\pgfarrowlinewidth\else 0pt\fi}%
    % Adjust inset
    \pgfarrowssetvisualbackend{\pgfarrowinset}
    \advance\pgfarrowinset by\pgf@yc%
    % The following are needed in the code:
    \pgfarrowssavethe\pgfutil@tempdima
    \pgfarrowssavethe\pgfutil@tempdimb
    \pgfarrowssavethe\pgfarrowlinewidth
    \pgfarrowssavethe\pgf@ya
    \pgfarrowssavethe\pgfarrowinset
  },
  drawing code = {
    \pgfsetdash{}{+0pt}%
    \ifpgfarrowroundjoin\pgfsetroundjoin\else\pgfsetmiterjoin\fi
    \ifdim\pgfarrowlinewidth=\pgflinewidth\else\pgfsetlinewidth{+\pgfarrowlinewidth}\fi
    \pgfpathmoveto{\pgfqpoint{\pgfutil@tempdima\advance\pgf@x by\pgf@ya}{-0.5\pgfarrowlinewidth}}%
    \pgfpathlineto{\pgfqpoint{\pgf@ya}{-0.5\pgfarrowlinewidth}}%
    \pgfpathlineto{\pgfqpoint{\pgfarrowinset}{-0.5\pgfarrowlinewidth}}%
    \ifpgfarrowharpoon \else
    \pgfpathlineto{\pgfqpoint{\pgf@ya}{-\pgfutil@tempdimb}}%
    \fi
    \pgfpathclose
    \ifpgfarrowopen\pgfusepathqstroke\else\ifdim\pgfarrowlinewidth>0pt\pgfusepathqfillstroke\else\pgfusepathqfill\fi\fi
    \pgfsetstrokecolor{\pgfarrowsecondcolor}%
    \pgfsetfillcolor{\pgfarrowsecondcolor}%
    \pgfpathmoveto{\pgfqpoint{\pgfutil@tempdima\advance\pgf@x by\pgf@ya}{0.5\pgfarrowlinewidth}}%
    \pgfpathlineto{\pgfqpoint{\pgf@ya}{0.5\pgfarrowlinewidth}}%
    \pgfpathlineto{\pgfqpoint{\pgfarrowinset}{0.5\pgfarrowlinewidth}}%
    \ifpgfarrowharpoon \else
    \pgfpathlineto{\pgfqpoint{\pgf@ya}{\pgfutil@tempdimb}}%
    \fi
    \pgfpathclose
    \ifpgfarrowopen\pgfusepathqstroke\else\ifdim\pgfarrowlinewidth>0pt\pgfusepathqfillstroke\else\pgfusepathqfill\fi\fi
  },
  parameters = {
    \pgfarrowsecondcolor,%
    \the\pgfarrowlinewidth,%
    \the\pgfarrowlength,%
    \the\pgfarrowwidth,%
    \the\pgfarrowinset,%
    \ifpgfarrowharpoon h\fi%
    \ifpgfarrowopen o\fi%
    \ifpgfarrowroundjoin j\fi%
  },
}%
\makeatother
\begin{document}
\begin{tikzpicture}
  \draw [thick,{Circle[open]}-{Siamese Stealth}] (0,0) -- ++ (70:1);
  \draw [thick,{Circle[fill=blue]}-{Siamese Stealth[second color=blue,length=10pt]}] (1,0) -- ++ (70:1);
  \draw [thick,{Circle[fill=orange]}-{Siamese Stealth[orange,second color=black,width=6pt]}] (2,0) -- ++ (70:1);
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

矢印の先についてはo、ライブラリで定義されていますが、ここで使用されているarrowsに置き換えられました。矢印の先は、 のより柔軟なバリエーションです。arrows.metaCircleo

もう 1 つの可能性は、 を使用することですpic。これは、pgf コア コマンドのない短縮コードですが、柔軟性も低くなります。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[pics/Siamese arrow/.style={code={
    \tikzset{Siamese arrow/.cd,#1}
    \def\pv##1{\pgfkeysvalueof{/tikz/Siamese arrow/##1}}%
    \begin{scope}
     \clip (-\pv{length}-5pt,0) -- (2pt,0) -- 
     (2pt,0.5*\pv{width}+\pgflinewidth)
      -- (-\pv{length}-5pt,0.5*\pv{width}+\pgflinewidth) -- cycle;
     \draw[-{\pv{head}[length=\pv{length},width=\pv{width}]},
        color=\pv{color 1}] (-\pv{length}+2pt,0) -- (2pt,0);
    \end{scope}
    \begin{scope}
     \clip (-\pv{length}-5pt,0) -- (2pt,0) -- 
     (2pt,-0.5*\pv{width}-\pgflinewidth)
      -- (-\pv{length}-5pt,-0.5*\pv{width}-\pgflinewidth) -- cycle;
     \draw[-{\pv{head}[length=\pv{length},width=\pv{width}]},
        color=\pv{color 2}] (-\pv{length}+2pt,0) -- (2pt,0);
    \end{scope}
    }},Siamese arrow/.cd,length/.initial=6pt,width/.initial=3pt,
    head/.initial=Stealth,color 1/.initial=black,color 2/.initial=red]
 %  
 \draw [thick,shorten >=2pt,{Circle[open]}-] (0,0) -- ++ (70:1)
  pic[pos=1,sloped]{Siamese arrow} ;
 \draw [thick,shorten >=2pt,{Circle[open]}-] (1,0) -- ++ (70:1)
  pic[pos=1,sloped]{Siamese arrow={width=5pt,color 1=blue,color 2=orange}} ;
 \draw [thick,shorten >=2pt,{Circle[open]}-] (2,0) -- ++ (70:1)
  pic[pos=1,sloped]{Siamese arrow={head=Latex,length=4pt,color 1=red,color 2=blue}} ;
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

関連情報