Cambiar la dirección de las puntas de flecha

Cambiar la dirección de las puntas de flecha

Estoy intentando dibujar un camino en tikz, usando la solución de Paul Gaborit aquí.TikZ: ¿Cómo dibujar una flecha en medio de la línea?Logré conseguir esto, donde el camino sería la mitad del anillo.

ingrese la descripción de la imagen aquí

Pero quiero que la flecha inferior izquierda y la flecha del semicírculo interior vayan hacia la derecha (para que todas las flechas tengan la misma dirección al atravesar el camino y tener el interior del anillo a la izquierda).

Mi pobre edición en paint.

ingrese la descripción de la imagen aquí

Y el código que estoy usando

 \usepackage{tikz}
 \usetikzlibrary{positioning, calc, arrows, decorations.markings, decorations.pathreplacing}

\tikzset{
  % style to apply some styles to each segment of a path
  on each segment/.style={
    decorate,
    decoration={
      show path construction,
      moveto code={},
      lineto code={
        \path [#1]
        (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
      },
      curveto code={
        \path [#1] (\tikzinputsegmentfirst)
        .. controls
        (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
        ..
        (\tikzinputsegmentlast);
      },
      closepath code={
        \path [#1]
        (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
      },
    },
  },
  % style to add an arrow in the middle of a path
  mid arrow/.style={postaction={decorate,decoration={
        markings,
        mark=at position .5 with {\arrow[#1]{stealth}}
      }}},
}


\begin{center}
\begin{tikzpicture}[domain=0:4]
\draw [<->, very thick] (0,4) node (yaxis) [above] {$y$}
    |- (-4,0) node (zaxis) [left] {}
    |- (4,0) node (xaxis) [right] {$x$}
    ;
   \path [draw=black, ultra thick, postaction={on each segment={mid arrow=black}}] (3,0) arc (0:180:3cm)
    (1,0) -> (3,0)
    (1,0) arc (0:180:1cm)
    (-1,0) -> (-3,0) ;
\end{tikzpicture}
\end{center}

Cualquier ayuda sería apreciada :)

Respuesta1

En el futuro, considere publicar un informe completoejemplo de trabajo mínimo (MWE). Hace que sea más fácil para otros comenzar a ayudarlo. :-)

El código de Paul Gaborit aplica las flechas en la dirección en la que se recorre el camino. Entonces, en este caso, todo lo que se necesita es cambiar la dirección de los segmentos del camino infractores.

Sólo tuve que cambiar dos líneas de código dentro del tikzpictureentorno; Ambos cambios se detallan en las líneas de comentarios en el código siguiente.

\documentclass[border=5pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning, calc, arrows, decorations.markings, decorations.pathreplacing}

\tikzset{
  % style to apply some styles to each segment of a path
  on each segment/.style={
    decorate,
    decoration={
      show path construction,
      moveto code={},
      lineto code={
        \path [#1]
        (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
      },
      curveto code={
        \path [#1] (\tikzinputsegmentfirst)
        .. controls
        (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
        ..
        (\tikzinputsegmentlast);
      },
      closepath code={
        \path [#1]
        (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
      },
    },
  },
  % style to add an arrow in the middle of a path
  mid arrow/.style={postaction={decorate,decoration={
        markings,
        mark=at position .5 with {\arrow[#1]{stealth}}
      }}},
}

\begin{document}
\begin{tikzpicture}[domain=0:4]
\draw [<->, very thick] (0,4) node (yaxis) [above] {$y$}
    |- (-4,0) node (zaxis) [left] {}
    |- (4,0) node (xaxis) [right] {$x$}
    ;
   \path [draw=black, ultra thick, postaction={on each segment={mid arrow=black}}] (3,0) arc (0:180:3cm)
    (1,0) -> (3,0)
    (-1,0) arc (180:0:1cm) % changed starting point and swapped arc bounding angles
    (-3,0) -> (-1,0) ; % swapped coordinates here
\end{tikzpicture}
\end{document}

ingrese la descripción de la imagen aquí

información relacionada