Seta e rótulo posicionados em um .pic usando tikz

Seta e rótulo posicionados em um .pic usando tikz

Estou tentando desenhar uma figura que contém repetidamente imagens semelhantes. Portanto, estou usando .pico fornecido por tikzda seguinte maneira:

\documentclass[tikz, border=2px]{standalone}
\usetikzlibrary{arrows.meta, bending, shapes.misc, shapes.geometric}

% define colors and other constants
\colorlet{line color}{black!30}
\def\line thickness{1pt}

% define primitive shapes for the drawing
\tikzset{
line/.style={
    -, draw=line color, line width=\line thickness},
z plus joint/.pic={
    \draw[black, line width=\line thickness, fill=gray!50]  (0,0)
          circle (0.5);
    \draw[black, line width=\line thickness, fill=white]  (0,0) circle (0.3);
    \draw[line width=2pt, red, -{Triangle[bend, length=6pt, width=8pt]}] 
          (270:0.4) arc (270:150:0.4);
    \draw[latex-,blue, shorten <=2pt] (-0.5, 0.5) -- ++ (-0.5, 0.5) 
          node[above=2pt, black]{#1};
         },
z minus joint/.pic={
    \pic[yscale=-1, rotate=180] {z plus joint=#1};},
}


\begin{document}
\begin{tikzpicture}[node distance=2cm]
    \path[line] (0, 0) pic {z plus joint=1} --
                (2, 0) pic {z minus joint=3} --
                (4, 0) pic {z minus joint=2} --
                (4, 2) pic {z plus joint=4} --
                (4, 4) pic {z minus joint=6};
\end{tikzpicture}
\end{document}

Veja abaixo a figura gerada:

insira a descrição da imagem aqui

Preciso dos dois tipos de orientação a seguir para setas:

  • Seta intitulada do lado esquerdo
  • Seta intitulada do lado direito

Estou procurando uma maneira de fornecer um argumento extra para a foto que possa decidir a orientação da seta.Por exemplo, veja o seguinte pseudocódigo:

\begin{tikzpicture}[node distance=2cm]
    \path[line] (0, 0) pic {z plus joint={1}{right}} --
                (2, 0) pic {z minus joint={3}{right}} --
                (4, 0) pic {z minus joint={2}{left}} --
                (4, 2) pic {z plus joint={4}{left}} --
                (4, 4) pic {z minus joint={6}{left}};
\end{tikzpicture}

PS: Como a orientação tem apenas dois valores possíveis, ou seja, lefte right, podemos ter leftcomodefault

Responder1

Algo assim? -1para esquerda e 1para direita.

\documentclass[tikz, border=2px]{standalone}
\usetikzlibrary{arrows.meta, bending, shapes.misc, shapes.geometric}

% define colors and other constants
\colorlet{line color}{black!30}
\def\line thickness{1pt}

% define primitive shapes for the drawing
\tikzset{
line/.style={
    -, draw=line color, line width=\line thickness},    
pics/z plus joint/.style n args={2}{code={
    \draw[black, line width=\line thickness, fill=gray!50]  (0,0)
          circle (0.5);
    \draw[black, line width=\line thickness, fill=white]  (0,0) circle (0.3);
    \draw[line width=2pt, red, -{Triangle[bend, length=6pt, width=8pt]}] 
          (270:0.4) arc (270:150:0.4);
    \draw[latex-,blue, shorten <=2pt] (0.5*#2, 0.5) -- ++ (0.5*#2, 0.5) 
          node[above=2pt, black]{#1};
         }},
pics/z minus joint/.style n args={2}{code={
    \pic[yscale=-1, rotate=180] {z plus joint={#1}{-1*#2}};}},
}


\begin{document}
\begin{tikzpicture}[node distance=2cm]
    \path[line] (0, 0) pic {z plus joint={1}{1}}
     --         (2, 0) pic {z minus joint={3}{1}} --
                (4, 0) pic {z minus joint={2}{-1}} --
                (4, 2) pic {z plus joint={4}{-1}} --
                (4, 4) pic {z minus joint={6}{-1}}
                ;
\end{tikzpicture}
\end{document}

insira a descrição da imagem aqui

informação relacionada