中心错位的 Tikz 图

中心错位的 Tikz 图

考虑以下一段代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{figure}[H]
            \centering
        \begin{tikzpicture}
        \begin{scope}[very thick,decoration={
            markings,
            mark=at position 0.5 with {\arrow{<}}}
        ] 
        \draw [dashed,blue,very thick,domain=162:-54] plot ({1.5*cos(\x)}, {1.5*sin(\x)});
        \draw [very thick,blue,domain=-54:-198] plot ({1.5*cos(\x)}, {1.5*sin(\x)});

%-----------------------------------------------------------------
    \path[draw=red, -stealth,
postaction={decorate,decoration={text effects along path,
        text={\ Positive direction\ }, text align=center,
        text effects/.cd, 
        text along path, 
        every character/.style={fill=white, yshift=-0.5ex}}}]
(0, 0) arc [start angle=-60, end angle=80, radius=4];
%--------------------------------------------------------------------
\draw[blue,very thick,postaction={decorate}] (0,1.5) -- (0,3) node[above] {\textcolor{black}{$ p_1 $}};
        \draw[blue,very thick,postaction={decorate}] (1.43,0.46) -- (2.85,0.93)node[align=right, above] {\textcolor{black}{$ p_2 $}};
        \draw[blue,very thick,postaction={decorate}] (0.88,-1.21) -- (1.76,-2.43)node[align=right, below] {\textcolor{black}{$ p_{N_c} $}};
        \draw[blue,very thick,postaction={decorate}] (-0.88,-1.21) -- (-1.76,-2.43)node[align=left, below] {\textcolor{black}{$ p_{N_c+1} $}};
        \draw[blue,very thick,postaction={decorate}] (-1.43,0.46) -- (-2.85,0.93)node[align=left, above] {\textcolor{black}{$ p_N $}};
        \draw [dotted,very thick,domain=172:224] plot ({2*cos(\x)}, {2*sin(\x)});
        \draw [dotted,very thick,domain=8:-44] plot ({2*cos(\x)}, {2*sin(\x)});
        \draw [thick,very thick,domain=162:90,->] plot ({1.3*cos(\x)}, {1.3*sin(\x)});
        \node[] at ({1*cos(126)},{1*sin(126)})   (a) {$ q $};
        \node[] at ({1.8*cos(126)},{1.8*sin(126)})   (a) {$ m_0 $};
        \node[] at ({1.8*cos(54)},{1.8*sin(54)})   (a) {$ m_1 $};

        \node[] at ({1.8*cos(90)},{-1.8*sin(90)})   (a) {$ m_{N_c} $};
        \end{scope}
        \end{tikzpicture}
  \end{figure}
\end{document}

在生成的图片中,红色圆弧的中心偏离了,尽管中心已设置为 (0,0)。问题是什么? 环形

答案1

arc操作从给定的点绘制圆弧。该点不是圆弧的中心。因此,如果您想以某个点为中心绘制圆弧,您可能需要calc(但calc在这种特殊情况下不是必需的)极坐标。

固定代码:

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.text}
\usetikzlibrary{decorations.markings}
\begin{document}
        \begin{tikzpicture}
        \begin{scope}[very thick,decoration={
            markings,
            mark=at position 0.5 with {\arrow{<}}}
        ] 
        \draw [dashed,blue,very thick,domain=162:-54] plot ({1.5*cos(\x)}, {1.5*sin(\x)});
        \draw [very thick,blue,domain=-54:-198] plot ({1.5*cos(\x)}, {1.5*sin(\x)});

%-----------------------------------------------------------------
    \path[draw=red, -stealth,
postaction={decorate,decoration={text effects along path,
        text={\ Positive direction\ }, text align=center,
        text effects/.cd, 
        text along path, 
        every character/.style={fill=white, yshift=-0.5ex}}}]
(-60:4) arc [start angle=-60, end angle=80, radius=4];
%--------------------------------------------------------------------
\draw[blue,very thick,postaction={decorate}] (0,1.5) -- (0,3) node[above] {\textcolor{black}{$ p_1 $}};
        \draw[blue,very thick,postaction={decorate}] (1.43,0.46) -- (2.85,0.93)node[align=right, above] {\textcolor{black}{$ p_2 $}};
        \draw[blue,very thick,postaction={decorate}] (0.88,-1.21) -- (1.76,-2.43)node[align=right, below] {\textcolor{black}{$ p_{N_c} $}};
        \draw[blue,very thick,postaction={decorate}] (-0.88,-1.21) -- (-1.76,-2.43)node[align=left, below] {\textcolor{black}{$ p_{N_c+1} $}};
        \draw[blue,very thick,postaction={decorate}] (-1.43,0.46) -- (-2.85,0.93)node[align=left, above] {\textcolor{black}{$ p_N $}};
        \draw [dotted,very thick,domain=172:224] plot ({2*cos(\x)}, {2*sin(\x)});
        \draw [dotted,very thick,domain=8:-44] plot ({2*cos(\x)}, {2*sin(\x)});
        \draw [thick,very thick,domain=162:90,->] plot ({1.3*cos(\x)}, {1.3*sin(\x)});
        \node[] at ({1*cos(126)},{1*sin(126)})   (a) {$ q $};
        \node[] at ({1.8*cos(126)},{1.8*sin(126)})   (a) {$ m_0 $};
        \node[] at ({1.8*cos(54)},{1.8*sin(54)})   (a) {$ m_1 $};

        \node[] at ({1.8*cos(90)},{-1.8*sin(90)})   (a) {$ m_{N_c} $};
        \end{scope}
        \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容