繪製兩個相鄰的節點圓

繪製兩個相鄰的節點圓

我希望使用 Tikz 繪製一個圖表,我可以將其形狀描述為類似於卡通中的槓鈴。一個最小的工作示例如下:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{center}
\begin{tikzpicture}[-,thick,scale=1]

\node (0) at (0,0) {0};
\node (1) at (-1,1) {1};
\node (2) at (-1,2) {2};
\node (3) at (0,3) {3};
\node (4) at (1,3) {4};
\node (5) at (2,2) {5};
\node (6) at (2,1) {6};
\node (7) at (1,0) {7};

\node (8) at (5,0) {8};
\node (9) at (4,1) {9};
\node (10) at (4,2) {10};
\node (11) at (5,3) {11};
\node (12) at (6,3) {12};
\node (13) at (7,2) {13};
\node (14) at (7,1) {14};
\node (15) at (6,0) {15};

\draw (0) to (1) to (2) to (3) to (4) to (5) to (6) to (7) to (0);
\draw (8) to (9) to (10) to (11) to (12) to (13) to (14) to (15) to (8);
\draw (5) to (10);
\draw (6) to (9);

\end{tikzpicture}
\end{center}

\end{document}

然而,我希望末端的節點圓類似於如下實現的節點圓:

\begin{center}
\begin{tikzpicture}[-,thick,scale=1]

\node (0) at (5*360/8 + 360/16: 1.6cm) {0};
\node (1) at (4*360/8 + 360/16: 1.6cm) {1};
\node (2) at (3*360/8 + 360/16: 1.6cm) {2};
\node (3) at (2*360/8 + 360/16: 1.6cm) {3};
\node (4) at (1*360/8 + 360/16: 1.6cm) {4};
\node (5) at (0*360/8 + 360/16: 1.6cm) {5};
\node (6) at (-1*360/8 + 360/16: 1.6cm) {6};
\node (7) at (-2*360/8 + 360/16: 1.6cm) {7};

\draw (0) to (1) to (2) to (3) to (4) to (5) to (6) to (7) to (0);

\end{tikzpicture}
\end{center}

但是,我不知道如何指定使用上述方法繪製的節點圓的中心和/或如何使用此方法繪製彼此相鄰的兩個節點圓。

答案1

看看,這是否是您正在尋找的:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{center}
\begin{tikzpicture}[-,thick,scale=1]
\node (10) at (5*360/8 + 360/16: 1.6cm) {0};
\node (11) at (4*360/8 + 360/16: 1.6cm) {1};
\node (12) at (3*360/8 + 360/16: 1.6cm) {2};
\node (13) at (2*360/8 + 360/16: 1.6cm) {3};
\node (14) at (1*360/8 + 360/16: 1.6cm) {4};
\node (15) at (0*360/8 + 360/16: 1.6cm) {5};
\node (16) at (-1*360/8 + 360/16: 1.6cm) {6};
\node (17) at (-2*360/8 + 360/16: 1.6cm) {7};

\draw (10) to (11) to (12) to (13) to (14) to (15) to (16) to (17) to (10);

    \begin{scope}[xshift=50mm]
\node (20) at (5*360/8 + 360/16: 1.6cm) {0};
\node (21) at (4*360/8 + 360/16: 1.6cm) {1};
\node (22) at (3*360/8 + 360/16: 1.6cm) {2};
\node (23) at (2*360/8 + 360/16: 1.6cm) {3};
\node (24) at (1*360/8 + 360/16: 1.6cm) {4};
\node (25) at (0*360/8 + 360/16: 1.6cm) {5};
\node (26) at (-1*360/8 + 360/16: 1.6cm) {6};
\node (27) at (-2*360/8 + 360/16: 1.6cm) {7};

\draw (20) to (21) to (22) to (23) to (24) to (25) to (26) to (27) to (20);
    \end{scope}

\draw (15) to (22)  (16) to (21); 
\end{tikzpicture}
\end{center} 
\end{document}

範例輸出

相關內容