如何绘制两侧都有节点的长方体

如何绘制两侧都有节点的长方体

有人能帮我制作以下一对物体吗:在左边,我们有一个长方体(2x3x3“立方体”),两侧的节点由虚线连接,在右边,长方体被切成两部分(节点也用虚线连接)在此处输入图片描述

答案1

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\def\a#1{\begin{scope}[yslant=0.7]
\draw[dotted] (0,0) grid[step=1cm] (2,2);
\draw (0,0) rectangle (2,2);
\foreach \x in {0,1,2}{\foreach \y in {0,1,2}{
\node[circle,fill,inner sep=2pt] (n-#1\x\y)at (\x,\y){};}}
\end{scope}}\a{a}\begin{scope}[shift={(2.5cm,0)}]\a{b}\end{scope}
\foreach \x in {0,2}{\foreach \y in {0,2}{\draw (n-a\x\y) --(n-b\x\y);}}
\begin{scope}[xshift=5cm]\a{c}\end{scope}
\begin{scope}[xshift=7.5cm]\a{d}\end{scope}
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

这更详细(仅用于比较):

\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\tikzset{mynode/.style={inner sep=1pt,fill,outer sep=0,circle}}

\begin{document}

\begin{tikzpicture}[scale=2,line width=0.5pt,x=2cm,baseline={(current bounding box.center)}]
  \foreach \x/\y/\z/\a in {0/0/0/1,0/1/0/2,1/1/0/3,1/0/0/4,0/0/1/5,0/1/1/6,1/1/1/7,1/0/1/8} {
    \coordinate (\a) at (\x,\y,\z);
    }

   \foreach \x/\y/\z/\a in  {0/0/0.5/11,0/1/0.5/21,0/0.5/0/31,0/0.5/1/41,
                     0/0.5/0.5/51,1/0/0.5/61,1/1/0.5/71,1/0.5/0/81, 1/0.5/1/91,1/0.5/0.5/101} {
    \coordinate (\a) at (\x,\y,\z);
    }


 \draw  (2) -- (3) -- (4);
 \draw (5) -- (6) -- (7) -- (8) -- cycle;
 \draw   (2) -- (6) (3) -- (7) (4) -- (8);

 \foreach \x in {1,2,...,8}{
     \node[mynode] at (\x) {};
 }

 \draw[dashed]  (1) -- (2)
        (1) -- (4)
        (1) -- (5);


 \draw[dashed] (11) -- (21)
                (31)--(41)
                (61) -- (71)
                (81) -- (91);


 \foreach \x in {11,21,...,101}{
     \node[mynode] at (\x) {};
 }

\end{tikzpicture}
\tikz\draw[thick,-latex] (0,0) -- (3,0);
\begin{tikzpicture}[scale=2,line width=0.5pt,x=2cm,baseline={(current bounding box.center)}]
  \foreach \x/\y/\z/\a in {0/0/0/1,0/1/0/2,1/1/0/3,1/0/0/4,0/0/1/5,0/1/1/6,1/1/1/7,1/0/1/8} {
    \coordinate (\a) at (\x,\y,\z);
    }

   \foreach \x/\y/\z/\a in  {0/0/0.5/11,0/1/0.5/21,0/0.5/0/31,0/0.5/1/41,
                     0/0.5/0.5/51,1/0/0.5/61,1/1/0.5/71,1/0.5/0/81, 1/0.5/1/91,1/0.5/0.5/101} {
    \coordinate (\a) at (\x,\y,\z);
    }


 \draw  (1) -- (5) -- (6) -- (2) -- cycle;
 \draw (4) -- (8) -- (7) -- (3) -- cycle;

 \foreach \x in {1,2,...,8}{
     \node[mynode] at (\x) {};
 }

 \draw[dashed] (11) -- (21)
                (31)--(41)
                (61) -- (71)
                (81) -- (91);


 \foreach \x in {11,21,...,101}{
     \node[mynode] at (\x) {};
 }

\end{tikzpicture}

\end{document}

在此处输入图片描述

答案3

这只是使用适合的 percusse 代码的另一种选择pics

\documentclass[tikz]{standalone}
\begin{document}

\tikzset{plane/.pic={
    \begin{scope}[yslant=0.7]
        \draw[dotted] (-1,-1) grid[step=1cm] (1,1);
        \draw (-1,-1) rectangle (1,1);
        \foreach \x in {-1,0,1}{
            \foreach \y in {-1,0,1}{
                \node[circle,fill,inner sep=2pt] (\x\y)at (\x,\y){};
            }
        }
    \end{scope}
    }
    }

\begin{tikzpicture}

\draw pic (a) {plane};
\draw pic (b) at (3,0) {plane};
\draw pic (c) at (7.5,0) {plane};
\draw pic (d) at (10.5,0) {plane};

\draw (a-1-1)--(b-1-1) (a-11)--(b-11) (a1-1)--(b1-1) (a11)--(b11);

\draw[-latex, shorten >=1cm,shorten <=1cm] (b00)--(c00);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容