节点之间的线

节点之间的线

我的问题是,是否有一种“简单”的方法可以在一个正方形的每个节点与对称绘制的其他正方形的每个节点之间画一条线,下面是我所说的代码。在此先感谢您的帮助。

\begin{tikzpicture}
  \begin{scope}[shift={(90:3)}, rotate=45]
    \foreach \x in{0,90,180,270}{\draw[blue] (\x:1)--(\x+90:1);};
    \foreach \x in{0,90,180,270}{\draw[blue] (\x:1)node[circle, fill=blue!20, draw]{};};
  \end{scope}
  \begin{scope}[shift={(210:3)}, rotate=165]
    \foreach \x in{0,90,180,270}{\draw[blue] (\x:1)--(\x+90:1);};
    \foreach \x in{0,90,180,270}{\draw[blue] (\x:1)node[circle, fill=blue!20, draw]{};};
  \end{scope}
  \begin{scope}[shift={(330:3)}, rotate=285]
    \foreach \x in{0,90,180,270}{\draw[blue] (\x:1)--(\x+90:1);};
    \foreach \x in{0,90,180,270}{\draw[blue] (\x:1)node[circle, fill=blue!20, draw]{};};
  \end{scope}
  %\foreach \x in{90,210,330}{\draw[thin] (0,0)--(\x:3);};
\end{tikzpicture}

答案1

抱歉,但我不太清楚矩形之间的点应该如何连接。像这样吗?

在此处输入图片描述

如果没有,请提供一个草图来表明你想要什么。

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
    \begin{tikzpicture}[
    node distance =6mm and 12mm,
dot/.style = {circle, draw=blue, fill=blue!20, inner sep=2pt},
  N/.style = {draw=blue, minimum size=10mm, node contents={}}
                        ]
\node (n1) [N]; 
\foreach \i [count=\j] in {north west, north east, south east, south west}
    \node (n1-\j) [dot] at (n1.\i) {};
\node (n2) [N, above right=of n1];
\foreach \i [count=\j] in {north west, north east, south east, south west}
    \node (n2-\j) [dot] at (n2.\i) {};
\node (n3) [N, below right=of n2];
\foreach \i [count=\j] in {north west, north east, south east, south west}
    \node (n3-\j) [dot] at (n3.\i) {};
\foreach \i in {1,2,3,4}
\draw[very thin, teal]  (n1-\i) -- (n2-\i)
                        (n2-\i) -- (n3-\i);
\foreach \i in {1,2,3,4}
\draw[very thin, teal]  (n1-\i) to[bend right=15] (n3-\i);
    \end{tikzpicture}
\end{document}

附录:
根据您的评论,这是起点,它展示了如何将一个矩形中的点连接到其他矩形中的所有点:

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
    \begin{tikzpicture}[
    node distance =6mm and 12mm,
dot/.style = {circle, draw=blue, fill=blue!20, inner sep=2pt},
  N/.style = {draw=blue, minimum size=10mm, node contents={}}
                        ]
\node (n1) [N];
\foreach \i [count=\j] in {north west, north east, south east, south west}
    \node (n1-\j) [dot] at (n1.\i) {};
\node (n2) [N, above right=of n1];
\foreach \i [count=\j] in {north west, north east, south east, south west}
    \node (n2-\j) [dot] at (n2.\i) {};
\node (n3) [N, below right=of n2];
\foreach \i [count=\j] in {north west, north east, south east, south west}
    \node (n3-\j) [dot] at (n3.\i) {};

\foreach \i in {1,2,3,4}
\draw[very thin, teal]  (n1-1) -- (n2-\i)
                        (n1-1) to[bend right] (n3-\i)
                        %
                        (n1-2) -- (n2-\i)
                        (n1-2) to[bend right] (n3-\i);
% etc. for connections of other dots I left to you
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容