答案1
也许下面的内容可以给你一个开始,然后你只需要根据你想要的每个模数调整代码:
\documentclass[tikz,border=3.14mm]{standalone}
\tikzset{dot/.style={circle,inner sep=1pt,outer sep=0pt,fill=black}}
\begin{document}
\begin{tikzpicture}
\def\r{3}
\node[draw=blue,circle,fill=cyan,minimum size=\r cm] {8 mod 4 = 0};
\foreach \i in {0,1,...,8}
{
\pgfmathsetmacro\im{int(\i/4)}
\node[dot] (p\i) at (90-\i*90:.75*\r+\im*.5){};
\ifnum\i<4
\node at (90-\i*90:.65*\r){\i};
\fi
\ifnum\i>0
\pgfmathtruncatemacro\j{\i-1}
\draw (p\j.center) to[bend left,looseness=1.5] (p\i.center);
\fi
}
\end{tikzpicture}
\end{document}
编辑:使用替代版本to[out=...,in=...]
您可以随意发挥,looseness
以获得漂亮的“方形”曲线。
\documentclass[tikz,border=3.14mm]{standalone}
\tikzset{dot/.style={circle,inner sep=1pt,outer sep=0pt,fill=black}}
\begin{document}
\begin{tikzpicture}
\def\r{3}
\node[draw=blue,circle,fill=cyan,minimum size=\r cm] {8 mod 4 = 0};
\foreach \i in {0,1,...,8}
{
\pgfmathsetmacro\im{int(\i/4)}
\node[dot] (p\i) at (90-\i*90:.75*\r+\im*.5){};
\ifnum\i<4
\node at (90-\i*90:.65*\r){\i};
\fi
\ifnum\i>0
\pgfmathtruncatemacro\j{\i-1}
\pgfmathsetmacro\imod{Mod(\i,4)}
\draw[olive] (p\j) to[out=-\imod*90+90,in=-\imod*90+180,looseness=1.5] (p\i);
\fi
}
\end{tikzpicture}
\end{document}
答案2
在我的提议中,我制作了一个宏,如果您提供数字(和图形的位置),它就会进行除法。这需要大量的“编程”(\foreach
、\ifnum
等),但我认为值得这样做,因为这样您就可以绘制所需的所有除法。
这就是我所拥有的:
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
% Definitions
\definecolor{myblue}{HTML}{C8C7FF}
\def\cr{1.25} % circle radius
\def\dr{0.05} % dot radius
\newcommand{\division}[3] % #1 mod #2 (#2 > 0), #3 -> position
{% #1 = q * #2 + r
\pgfmathtruncatemacro\p{abs(#1)}
\pgfmathtruncatemacro\s{#1 < 0 ? 1 : -1} % sign
\pgfmathtruncatemacro\q{\p/#2} % quotient
\pgfmathtruncatemacro\r{Mod(#1,#2)} % residue
\begin{scope}[shift={#3}, x={(0 cm,1 cm)}, y={(\s cm, 0 cm)}]
\draw[fill=myblue] (0,0) circle (\cr) node {$#1 \bmod #2 = \r$};
\foreach\i in {1,...,#2}
{% first turn of dots (mandatory, we are drawing all the labels)
\pgfmathtruncatemacro\j{\i-1}
\pgfmathsetmacro\an{-360*\j/#2} % angle
\pgfmathsetmacro\nr{2.25*\cr+0.25*\j*\cr/#2} % radius
\pgfmathsetmacro\n{#1*\j >= 0 ? \j : int(#2-\j)} % node label
\coordinate (n\j) at (\an:\nr);
\node at (\an:2*\cr) {$\n$};
\fill (n\j) circle (\dr);
}
\foreach\i in {1,...,\p}
{% rest of the turns of dots and all the edges
\pgfmathtruncatemacro\j{\i-1}
\pgfmathsetmacro\an{-360*\i/#2} % angle
\pgfmathsetmacro\nr{2.25*\cr+0.25*\i*\cr/#2} % radius
\unless\ifnum\i < #2 % if it isn't drawn in the first turn
\coordinate (n\i) at (\an:\nr);
\fill (n\i) circle (\dr);
\fi
\draw (n\j) to[bend left=-180*\s/#2+10*\s] (n\i);
}
\end{scope}
}
\begin{document}
\begin{tikzpicture}
\division{ 8}{4}{( 0,8)}
\division{ 7}{2}{( 7,8)}
\division{-5}{3}{(14,8)}
\division{11}{5}{( 0,0)}
\division{ 1}{3}{( 7,0)}
\division{-9}{3}{(14,0)}
\end{tikzpicture}
\end{document}