화살촉 방향 변경

화살촉 방향 변경

여기 Paul Gaborit의 솔루션을 사용하여 tikz에서 경로를 그리려고 합니다.TikZ: 선 중앙에 화살표를 그리는 방법은 무엇입니까?나는 이것을 얻을 수 있었는데, 경로는 고리의 절반이 될 것입니다.

여기에 이미지 설명을 입력하세요

그러나 나는 왼쪽 하단 화살표와 내부 반원 화살표가 오른쪽으로 이동하기를 원합니다. 따라서 경로를 횡단하고 고리 내부가 왼쪽에 있을 때 모든 화살표가 동일한 방향을 갖습니다.

내 페인트 편집이 좋지 않음

여기에 이미지 설명을 입력하세요

그리고 내가 사용하는 코드는

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

어떤 도움이라도 주시면 감사하겠습니다 :)

답변1

앞으로는 전체 게시물을 게시하는 것을 고려해 보세요.최소 작업 예(MWE). 그러면 다른 사람들이 당신을 돕기 시작하는 것이 더 쉬워집니다. :-)

Paul Gaborit의 코드는 경로가 통과하는 방향으로 화살표를 적용합니다. 따라서 이 경우에는 문제가 되는 경로 세그먼트의 방향을 변경하기만 하면 됩니다.

환경 내에서 두 줄의 코드만 변경하면 되었습니다 tikzpicture. 이러한 변경 사항은 모두 아래 코드의 주석 줄에 자세히 설명되어 있습니다.

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

여기에 이미지 설명을 입력하세요

관련 정보