用圆弧和箭头连接节点

用圆弧和箭头连接节点

在以下 MWE 中:我尝试使用圆弧和箭头连接节点、和CA我能够用直线连接它们,但阅读这里的一些文档后,我仍然无法做到这一点。我画了一个圆圈,它应该显示我想要的路径,但箭头方向为逆时针。ST

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
    \begin{tikzpicture}[scale=4,cap=round,>=latex]
        \draw[->] (-1.125cm,0cm) -- (1.125cm,0cm) node[right,fill=white] {$x$};
        \draw[->] (0cm,-1.125cm) -- (0cm,1.125cm) node[above,fill=white] {$y$};
        \draw[thick] (0cm,0cm) circle(1cm);
            \foreach \x/\xtext/\xcoordinate in {
                45/QI/{(x>0,y>0)}, 
                135/QII/{(x<0,y>0)}, 
                225/QIII/{(x<0,y<0)}, 
                315/QIV/{(x>0,y<0)}} 
                {%
                    \draw (\x:0.65cm) node[fill=white,text width=2.5cm,align=center]
                    {\xtext \\ $\xcoordinate$};
                }
            \draw[thick] (0cm,0cm) circle(0.3cm);
            \foreach \y/\ytext in {
                45/A, 
                135/S, 
                225/T, 
                315/C} 
                {%
                    \draw (\y:0.3cm) node[shape=circle,fill=white,text width=1cm,align=center,font=\bfseries\large,text=black,inner sep=0pt]
                    {\ytext}coordinate (\ytext);
                }
            \draw[-latex,shorten <= 10pt,shorten >= 10pt] (S) -- (T);
            \draw[-latex,shorten <= 10pt,shorten >= 10pt] (A) -- (S);
            \draw[-latex,shorten <= 10pt,shorten >= 10pt] (C) -- (A);
            \draw[-latex,shorten <= 10pt,shorten >= 10pt] (T) -- (C);
    \end{tikzpicture}
\end{document}

这是我目前所拥有的:

在此处输入图片描述

我最接近的尝试是使用:

\draw[shorten <= 10pt,shorten >= 10pt,bend right,->]  (C) to (A);
\draw[shorten <= 10pt,shorten >= 10pt,bend right,->]  (A) to (S);
\draw[shorten <= 10pt,shorten >= 10pt,bend right,->]  (S) to (T);
\draw[shorten <= 10pt,shorten >= 10pt,bend right,->]  (T) to (C);

这就是我所寻找的: 在此处输入图片描述

答案1

让我回收这个答案并根据您的设置进行调整。问题总是一样的:在圆弧上连接节点。一个答案是构造一个实际的圆,并计算与节点边界的交点。幸运的是,您已经将它们视为圆形,因此真正要做的就是命名路径,即将密钥添加到圆形节点name path=\ytext。(顺便说一句,您可以命名节点,无需添加额外的坐标。)这产生:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,bending,calc,intersections}
\tikzset{pics/circular arc/.style args={from #1 to #2}{code={
  \def\pv##1{\pgfkeysvalueof{/tikz/circular arc/##1}} 
  \path[name path=arc,draw=none] 
   let \p1=(#1),\p2=(#2),\n1={Mod(720+atan2(\y1,\x1),360)},
   \n2={Mod(720+atan2(\y2,\x2),360)},
     \n3={ifthenelse(abs(\n1-\n2)<180,\n2,\n2+360)}
   in    (\n1:\pv{r}) arc(\n1:\n3:\pv{r});
 \draw[pic actions,
    name intersections={of=#1 and arc,by=arcstart},
    name intersections={of=#2 and arc,by=arcend}] 
    let \p1=(arcstart),\p2=(arcend),\n1={Mod(720+atan2(\y1,\x1),360)},
     \n2={Mod(720+atan2(\y2,\x2),360)},
     \n3={ifthenelse(abs(\n1-\n2)<180,\n2,\n2+360)}
  in (\n1:\pv{r}) arc(\n1:\n3:\pv{r});
 }},circular arc/.cd,r/.initial=0.3cm}
\begin{document}
    \begin{tikzpicture}[scale=4,line cap=round,>=latex]
        \draw[->] (-1.125cm,0cm) -- (1.125cm,0cm) node[right,fill=white] {$x$};
        \draw[->] (0cm,-1.125cm) -- (0cm,1.125cm) node[above,fill=white] {$y$};
        \draw[thick] (0cm,0cm) circle(1cm);
            \foreach \x/\xtext/\xcoordinate in {
                45/QI/{(x>0,y>0)}, 
                135/QII/{(x<0,y>0)}, 
                225/QIII/{(x<0,y<0)}, 
                315/QIV/{(x>0,y<0)}} 
                {%
                    \draw (\x:0.65cm) node[fill=white,text width=2.5cm,align=center]
                    {\xtext \\ $\xcoordinate$};
                }
            \draw[thick] (0cm,0cm) circle(0.3cm);
            \foreach \y/\ytext in {
                45/A, 
                135/S, 
                225/T, 
                315/C} 
                {%
                    \draw (\y:0.3cm) 
                    node[shape=circle,name path=\ytext,
                    fill=white,text width=1cm,align=center,
                    font=\bfseries\large,text=black,inner sep=0pt]
                    (\ytext){\ytext};
                }
            \path[shorten >=-2pt,-{Latex[bend]},transform shape] pic{circular arc=from S to T}
             pic{circular arc=from T to C} 
             pic{circular arc=from C to A}
              pic{circular arc=from A to S};
            %\draw[red,ultra thin] (0,0) circle[radius=0.3cm];  
    \end{tikzpicture}
\end{document}

在此处输入图片描述

如果你取消注释该行

\draw[red,ultra thin] (0,0) circle[radius=0.3cm];  

你得到

在此处输入图片描述

表明弧线确实沿着圆圈运动。

如果你text width=1cm用替换text width=1.75em,你会得到

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,bending,calc,intersections}
\tikzset{pics/circular arc/.style args={from #1 to #2}{code={
  \def\pv##1{\pgfkeysvalueof{/tikz/circular arc/##1}} 
  \path[name path=arc,draw=none] 
   let \p1=(#1),\p2=(#2),\n1={Mod(720+atan2(\y1,\x1),360)},
   \n2={Mod(720+atan2(\y2,\x2),360)},
     \n3={ifthenelse(abs(\n1-\n2)<180,\n2,\n2+360)}
   in    (\n1:\pv{r}) arc(\n1:\n3:\pv{r});
 \draw[pic actions,
    name intersections={of=#1 and arc,by=arcstart},
    name intersections={of=#2 and arc,by=arcend}] 
    let \p1=(arcstart),\p2=(arcend),\n1={Mod(720+atan2(\y1,\x1),360)},
     \n2={Mod(720+atan2(\y2,\x2),360)},
     \n3={ifthenelse(abs(\n1-\n2)<180,\n2,\n2+360)}
  in (\n1:\pv{r}) arc(\n1:\n3:\pv{r});
 }},circular arc/.cd,r/.initial=0.3cm}
\begin{document}
    \begin{tikzpicture}[scale=4,line cap=round,>=latex]
        \draw[->] (-1.125cm,0cm) -- (1.125cm,0cm) node[right,fill=white] {$x$};
        \draw[->] (0cm,-1.125cm) -- (0cm,1.125cm) node[above,fill=white] {$y$};
        \draw[thick] (0cm,0cm) circle(1cm);
            \foreach \x/\xtext/\xcoordinate in {
                45/QI/{(x>0,y>0)}, 
                135/QII/{(x<0,y>0)}, 
                225/QIII/{(x<0,y<0)}, 
                315/QIV/{(x>0,y<0)}} 
                {%
                    \draw (\x:0.65cm) node[fill=white,text width=2.5cm,align=center]
                    {\xtext \\ $\xcoordinate$};
                }
            \draw[thick] (0cm,0cm) circle(0.3cm);
            \foreach \y/\ytext in {
                45/A, 
                135/S, 
                225/T, 
                315/C} 
                {%
                    \draw (\y:0.3cm) 
                    node[shape=circle,name path global=\ytext,
                    fill=white,text width=1.75em,align=center,
                    font=\bfseries\large,text=black,inner sep=0pt]
                    (\ytext){\ytext};
                }
            \path[shorten >=-2pt,-{Latex[bend]},transform shape] pic{circular arc=from S to T}
             pic{circular arc=from T to C} 
             pic{circular arc=from C to A}
              pic{circular arc=from A to S};
            %\draw[red,ultra thin] (0,0) circle[radius=0.3cm];  
    \end{tikzpicture}
\end{document}

在此处输入图片描述

此代码也使用name path global而不是name path。 (在我更新的 TeXLive 2019 安装中,我不需要global。)

最后,如果所有节点确实具有相同的大小,那么您只需使用简单的弧即可。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows.meta,bending}
\begin{document}
    \begin{tikzpicture}[scale=4,line cap=round,>=latex]
        \draw[->] (-1.125cm,0cm) -- (1.125cm,0cm) node[right,fill=white] {$x$};
        \draw[->] (0cm,-1.125cm) -- (0cm,1.125cm) node[above,fill=white] {$y$};
        \draw[thick] (0cm,0cm) circle(1cm);
            \foreach \x/\xtext/\xcoordinate in {
                45/QI/{(x>0,y>0)}, 
                135/QII/{(x<0,y>0)}, 
                225/QIII/{(x<0,y<0)}, 
                315/QIV/{(x>0,y<0)}} 
                {%
                    \draw (\x:0.65cm) node[fill=white,text width=2.5cm,align=center]
                    {\xtext \\ $\xcoordinate$};
                }
            \draw[thick] (0cm,0cm) circle(0.3cm);
            \foreach \y/\ytext in {
                45/A, 
                135/S, 
                225/T, 
                315/C} 
                {%
                    \draw (\y:0.3cm) 
                    node[shape=circle,
                    fill=white,text width=1.75em,align=center,
                    font=\bfseries\large,text=black,inner sep=0pt]
                    (\ytext){\ytext};
                }
            \foreach \X in {0,...,3} 
            {\draw[-{Latex[bend]}] (\X*90-30:0.3cm) arc(\X*90-30:\X*90+30:0.3cm);}
            %\draw[red,ultra thin] (0,0) circle[radius=0.3cm];  
    \end{tikzpicture}
\end{document}

在此处输入图片描述

您可以根据需要调整该值30以使箭头更长或更短。这可以正常工作,但箭头不会根据节点的大小调整其长度。在您使用固定设置时,text width您可以防止节点增长,因此此解决方案应该没问题。

答案2

我认为正确的方法是使用 angles 包。看看以下内容是否是您想要的:

编辑:创建“辅助”节点C2,,A2S2T2

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{angles}
\begin{document}
    \begin{tikzpicture}[scale=4,cap=round,>=latex]
        \draw[->] (-1.125cm,0cm) -- (1.125cm,0cm) node[right,fill=white] {$x$};
        \draw[->] (0cm,-1.125cm) -- (0cm,1.125cm) node[above,fill=white] {$y$};
        \draw[thick] (0cm,0cm) circle(1cm);
            \foreach \x/\xtext/\xcoordinate in {
                45/QI/{(x>0,y>0)}, 
                135/QII/{(x<0,y>0)}, 
                225/QIII/{(x<0,y<0)}, 
                315/QIV/{(x>0,y<0)}} 
                {%
                    \draw (\x:0.65cm) node[fill=white,text width=2.5cm,align=center]
                    {\xtext \\ $\xcoordinate$};
                }

            \foreach \y/\ytext in {
                45/A, 
                135/S, 
                225/T, 
                315/C} 
                {%
                    \draw (\y:0.3cm) node[]
                    {\ytext}coordinate (\ytext);
                }
            \node[] at (0cm,0cm) (O) {};
            \node[] at ([yshift=1, xshift=1]S) (S2) {};
            \node[] at ([yshift=-1, xshift=1]A) (A2) {};
            \node[] at ([yshift=1,xshift=-1]T) (T2) {};
            \node[] at ([xshift=-1]C) (C2) {};

            \pic [draw, ->, angle radius=1.5cm] {angle = A--O--S2};
            \pic [draw, ->, angle radius=1.5cm] {angle = S--O--T2};
            \pic [draw, ->, angle radius=1.5cm] {angle = T--O--C2};
            \pic [draw, ->, angle radius=1.5cm] {angle = C--O--A2};


    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容