Tikz:修改一些螺旋状的弧层以形成圆形的层

Tikz:修改一些螺旋状的弧层以形成圆形的层

我从编辑以下代码回答这个问题

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
        \tikzset{declare function={hourstoangle(\h) = 90-(\h)*360/12;}}
        \def\dialR{3cm} % dial radius
        
        % dial
        %\draw (0,0) circle[radius=\dialR];
        
        % hour tips
        %\foreach \num in {1,...,12}{
            %\draw ({hourstoangle(\num)}:\dialR)-- ++({hourstoangle(\num)}:-1mm);
        %}
        
        % hour labels
        %\foreach \num in {1,...,12}{
            %\draw ({hourstoangle(\num)}:\dialR-5mm) node{\num};
        %}
        
        % arcs
        \foreach \num in {0,...,11}{%\foreach \num in {0,...,12}{ I only need 12 and not 13 arcs
            \pgfmathsetmacro\dist{\dialR+2mm+2mm*\num}
            
            \draw
            % two tips
            ({hourstoangle(\num)}:\dist pt-1mm) -- ({hourstoangle(\num)}:\dist pt+1mm)
            ({hourstoangle(\num+3)}:\dist pt-1mm) -- ({hourstoangle(\num+3)}:\dist pt+1mm)
            % one arc
            ({hourstoangle(\num)}:\dist pt)
            arc[start angle={hourstoangle(\num)},end angle={hourstoangle(\num+3)},radius=\dist pt];
        }
        
        
    \end{tikzpicture}
\end{document}

我想要的是

  1. 我希望能够标记每个弧,就像我在下图中手动完成的那样。

  2. 我希望能够将外层的一些弧线移动到有空格的内层。例如,将B_4和移动B_7到的同一层B_1,而将B_5B_8重新定位到“B_2”的同一层,并将B_6重新定位到的同一层 B_3。这样整个图片将是一个由 3 层组成的圆圈,而不是螺旋。

如第一张图片所示以下

我希望标记的弧嵌入每个 ack 的中心,类似于下面第二张图片

答案1

编辑3

曲线上有标签的螺旋版本,您可以按照我之前给您的提示自己制作。无论如何,它在这里:

版本 4

    \begin{tikzpicture}
        \tikzset{declare function={hourstoangle(\h) = 90-(\h)*360/12;}}
        \def\dialR{3cm} % dial radius
        
        % dial
        %\draw (0,0) circle[radius=\dialR];
        
        % hour tips
        %\foreach \num in {1,...,12}{
            %\draw ({hourstoangle(\num)}:\dialR)-- ++({hourstoangle(\num)}:-1mm);
        %}
        
        % hour labels
        %\foreach \num in {1,...,12}{
            %\draw ({hourstoangle(\num)}:\dialR-5mm) node{\num};
        %}
        
        % arcs
        \foreach \num [count= \n from 1] in {0,...,11}{%\foreach \num in {0,...,12}{ I only need 12 and not 13 arcs
            \pgfmathsetmacro\dist{\dialR+2mm+2mm*\num}
            
            \draw
            % two tips
            ({hourstoangle(\num)}:\dist pt-1mm) -- ({hourstoangle(\num)}:\dist pt+1mm)
            ({hourstoangle(\num+3)}:\dist pt-1mm) -- ({hourstoangle(\num+3)}:\dist pt+1mm)
            % one arc
            ({hourstoangle(\num)}:\dist pt)
            arc[start angle={hourstoangle(\num)},end angle={hourstoangle(\num+3)},radius=\dist pt] node[sloped,midway,fill=white,inner sep=1pt,allow upside down]{$B_{\n}$};
        }
        
        
    \end{tikzpicture}
    \begin{tikzpicture}
        \tikzset{declare function={hourstoangle(\h) = 90-(\h)*360/12;}}
        \def\dialR{3cm} % dial radius
        
        % dial
        %\draw (0,0) circle[radius=\dialR];
        
        % hour tips
        %\foreach \num in {1,...,12}{
            %\draw ({hourstoangle(\num)}:\dialR)-- ++({hourstoangle(\num)}:-1mm);
        %}
        
        % hour labels
        %\foreach \num in {1,...,12}{
            %\draw ({hourstoangle(\num)}:\dialR-5mm) node{\num};
        %}
        
        % arcs
        \foreach \num [count= \n from 1] in {0,...,11}{%\foreach \num in {0,...,12}{ I only need 12 and not 13 arcs
            \pgfmathsetmacro\dist{\dialR+2mm+2mm*\num}
            
            \draw
            % two tips
            ({hourstoangle(\num)}:\dist pt-1mm) -- ({hourstoangle(\num)}:\dist pt+1mm)
            ({hourstoangle(\num+3)}:\dist pt-1mm) -- ({hourstoangle(\num+3)}:\dist pt+1mm)
            % one arc
            ({hourstoangle(\num)}:\dist pt)
            arc[start angle={hourstoangle(\num)},end angle={hourstoangle(\num+3)},radius=\dist pt] node[sloped,midway,fill=white,inner sep=1pt,allow upside down]{$B_{\n}$};
        }
        
        
    \end{tikzpicture}

编辑

allow upside down如果您希望每个节点都位于圆圈的外部空间,则可以使用以下版本。

版本 2

\documentclass[tikz,border=3.14mm]{standalone}

\begin{document}
    \begin{tikzpicture}
        \tikzset{declare function={hourstoangle(\h) = 90-(\h)*360/12;}}
        \def\dialR{3cm} % dial radius
        
        % dial
        %\draw (0,0) circle[radius=\dialR];
        
        % hour tips
        %\foreach \num in {1,...,12}{
            %\draw ({hourstoangle(\num)}:\dialR)-- ++({hourstoangle(\num)}:-1mm);
        %}
        
        % hour labels
        %\foreach \num in {1,...,12}{
            %\draw ({hourstoangle(\num)}:\dialR-5mm) node{\num};
        %}
        
        % arcs
        \foreach \num [count= \n from 1] in {0,...,11}{%\foreach \num in {0,...,12}{ I only need 12 and not 13 arcs
            \pgfmathsetmacro\dist{\dialR+2mm+2mm*\num}
            
            \draw
            % two tips
            ({hourstoangle(\num)}:\dist pt-1mm) -- ({hourstoangle(\num)}:\dist pt+1mm)
            ({hourstoangle(\num+3)}:\dist pt-1mm) -- ({hourstoangle(\num+3)}:\dist pt+1mm)
            % one arc
            ({hourstoangle(\num)}:\dist pt)
            arc[start angle={hourstoangle(\num)},end angle={hourstoangle(\num+3)},radius=\dist pt] node[sloped,midway,above]{$B_{\n}$};
        }
        
        
    \end{tikzpicture}

    
    \begin{tikzpicture}
        \tikzset{declare function={hourstoangle(\h) = 90-(\h)*360/12;}}
        \def\dialR{3cm} % dial radius
        
        \newcommand{\drawcircle}[1]{
            \pgfmathsetmacro\dist{\dialR+#1 mm}
            
            \draw
            % two tips
            ({hourstoangle(\num)}:\dist pt-1mm) -- ({hourstoangle(\num)}:\dist pt+1mm)
            ({hourstoangle(\num+3)}:\dist pt-1mm) -- ({hourstoangle(\num+3)}:\dist pt+1mm)
            % one arc
            ({hourstoangle(\num)}:\dist pt)
            arc[start angle={hourstoangle(\num)},end angle={hourstoangle(\num+3)},radius=\dist pt] node[sloped,midway,above,allow upside down]{$B_{\n}$};}
        % arcs
        \foreach \num [evaluate = \num as \n using int(\num+1)] in {0,3,6,9}{%
            \drawcircle{0}
        }
        \foreach \num [evaluate = \num as \n using int(\num+1)] in {1,4,7,10}{%
            \drawcircle{6}
        }
        \foreach \num [evaluate = \num as \n using int(\num+1)] in {2,5,8,11}{%
            \drawcircle{12}
        }
       
        
        
    \end{tikzpicture}   
    
\end{document}

编辑2

通过稍微改变节点参​​数,你就可以得到你想要的:

node[sloped,midway,fill=white,inner sep=1pt,allow upside down]代替node[sloped,midway,above,allow upside down]

版本 3

顺便说一句,既然你已经在这个网站上待了一段时间了,你可能会从你得到的许多答案中受益,从而了解一点关于 TiZ. 也许你应该尝试一下 ;)

相关内容