立方体内的 3D 立方体?

立方体内的 3D 立方体?

我一直想制作一个图像,但没有成功。通常我使用 tikz 环境,但仍然搞不懂。

我需要帮助!谢谢!我正在尝试创建的手绘图像

第一节代码图像结果

\documentclass{article}
 \usepackage{tikz}
 \begin{document}
 \pagestyle{empty}

  \begin{figure}[bt]
  \centering
  \scalebox{0.6}
 {
 \begin{tikzpicture}[scale=5]
 \tikzstyle{vertex}=[circle,minimum size=20pt,inner sep=0pt]
 \tikzstyle{selected vertex} = [vertex, fill=red!24]
 \tikzstyle{selected edge} = [draw,line width=5pt,-,red!50]
 \tikzstyle{edge} = [draw,thick,-,black]
 \node[vertex] (v0) at (0.5,0.5) {};
 \node[vertex] (v1) at (0.5,1) {};
 \node[vertex] (v2) at (1,0.5) {};
 \node[vertex] (v3) at (1,1) {$V$};
 \node[vertex] (v4) at (0.615, 0.7) {$C$};
 \node[vertex] (v5) at (0.615,1.2) {};
 \node[vertex] (v6) at (1.14,0.7) {};
 \node[vertex] (v7) at (1.14, 1.2) {};

 \node[vertex] (v8) at (-0.5,-0.5) {};
 \node[vertex] (v9) at (-0.5, 1) {};
 \node[vertex] (v13) at (-0.08,1.6) {};
 \node[vertex] (v12) at (-0.08, 0.1) {};
 \node[vertex] (v10) at (1,-0.5) {};
 \node[vertex] (v14) at (1.42,0.1) {};
 \node[vertex] (v11) at (1,1) {};
 \node[vertex] (v15) at (1.42, 1.6) {};

 \draw[edge] (v0) -- (v1) -- (v3) -- (v2) -- (v0);
 \draw[edge] (v0) -- (v4) -- (v5) -- (v1) -- (v0);
 \draw[edge] (v2) -- (v6) -- (v7) -- (v3) -- (v2);
 \draw[edge] (v4) -- (v6) -- (v7) -- (v5) -- (v4);

 \draw[edge] (v8) -- (v9) -- (v13) -- (v12) -- (v8);
 \draw[edge] (v8) -- (v10) -- (v14) -- (v12) -- (v8);
 \draw[edge] (v10) -- (v11) -- (v15) -- (v14) -- (v10);
 \draw[edge] (v9) -- (v11) -- (v15) -- (v13) -- (v9);

  \end{tikzpicture}
  }
  \end{figure}
 \end{document}

第二段代码图像结果

 \usetikzlibrary{positioning}
 \large
 \pagestyle{empty}
 \begin{figure}

 \begin{tikzpicture}
        [cube/.style={very thick,black},
            grid/.style={very thin,gray},
            axis/.style={->,black,thick}]

 \begin{tikzpicture}[every node/.style={minimum size=1cm},on grid]
 \begin{scope}[every node/.append style={yslant=-0.5},yslant=-0.5]
 [cube/.style={very thick,black},
            axis/.style={->,blue,thick}]
   \draw[axis] (5,5,0) -- (-2,-2,0) node[anchor=west]{$x$};
   \shade[right color=gray!10, left color=black!50] (0,0) rectangle +(3,3);
   \node at (0.5,2.5) {};
   \node at (1.5,2.5) {};
   \node at (2.5,2.5) {};
   \node at (0.5,1.5) {};
   \node at (1.5,1.5) {};
   \node at (2.5,1.5) {};
   \node at (0.5,0.5) {};
   \node at (1.5,0.5) {};
   \node at (2.5,0.5) {};
   \draw (0,0) grid (3,3);
 \end{scope}

 \begin{scope}[every node/.append style={yslant=0.5},yslant=0.5]
 \draw[axis] (3,0,0) -- (8,-5,0) node[anchor=west]{$y$};

   \shade[right color=gray!70,left color=gray!10] (3,-3) rectangle +(3,3);
   \node at (3.5,-0.5) {};
   \node at (4.5,-0.5) {};
   \node at (5.5,-0.5) {};
   \node at (3.5,-1.5) {};
   \node at (4.5,-1.5) {};
   \node at (5.5,-1.5) {};
   \node at (3.5,-2.5) {};
   \node at (4.5,-2.5) {};
   \node at (5.5,-2.5) {};
   \draw (3,-3) grid (6,0);
 \end{scope}

 \begin{scope}[every node/.append style={
     yslant=0.5,xslant=-1},yslant=0.5,xslant=-1
   ]
   \draw[axis] (3,0,0) -- (8,5,0) node[anchor=west]{$z$};
   \shade[bottom color=gray!10, top color=black!80] (6,3) rectangle +(-3,-3);
   \node at (3.5,2.5) {};
   \node at (3.5,1.5) {};
   \node at (3.5,0.5) {};
   \node at (4.5,2.5) {};
   \node at (4.5,1.5) {};
   \node at (4.5,0.5) {};
   \node at (5.5,2.5) {};
   \node at (5.5,1.5) {};
   \node at (5.5,0.5) {};
   \draw (3,0) grid (6,3);  
 \end{scope}
 \end{tikzpicture}
 \end{tikzpicture}
 \end{figure}

答案1

这是另一个选项tikz-3dplot

在此处输入图片描述

代码;\BigSide\SmallSide允许您轻松更改两侧的值:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{patterns}

\begin{document}

\tdplotsetmaincoords{70}{120}
\begin{tikzpicture}[tdplot_main_coords]
\def\BigSide{5}
\def\SmallSide{1.5}
\pgfmathsetmacro{\CalcSide}{\BigSide-\SmallSide}

% The vertex at V
\tdplotsetcoord{P}{sqrt(3)*\BigSide}{55}{45}

\coordinate (sxl) at (\BigSide,\CalcSide,\BigSide);
\coordinate (syl) at (\CalcSide,\CalcSide,\BigSide);
\coordinate (szl) at (\CalcSide,\BigSide,\BigSide);

\draw[dashed] 
  (0,0,0) -- (Px)
  (0,0,0) -- (Py)
  (0,0,0) -- (Pz);
\draw[->] 
  (Px) -- ++ (1,0,0) node[anchor=north east]{$x$};
\draw[->]
   (Py) -- ++(0,1,0) node[anchor=north west]{$y$};
\draw[->] 
  (Pz) -- ++(0,0,1) node[anchor=south]{$z$};

\draw[thick]
  (Pxz) -- (P) -- (Pxy) -- (Px) -- (Pxz) -- (Pz) -- (Pyz) -- (P); 
\draw[thick]
  (Pyz) -- (Py) -- (Pxy);

\fill[pattern=north west lines,opacity=0.3]
  (\BigSide,\CalcSide,\CalcSide) -- (\CalcSide,\CalcSide,\CalcSide) -- (\CalcSide,\BigSide,\CalcSide) -- (\BigSide,\BigSide,\CalcSide) -- cycle;  
\draw[dashed]
  (\BigSide,\CalcSide,\CalcSide) -- (\CalcSide,\CalcSide,\CalcSide) coordinate (C) -- (\CalcSide,\BigSide,\CalcSide);

\fill[pattern=north east lines,opacity=0.3]
  (\BigSide,\CalcSide,\CalcSide) -- (\CalcSide,\CalcSide,\CalcSide) -- (\CalcSide,\CalcSide,\BigSide) -- (\BigSide,\CalcSide,\BigSide) -- (\BigSide,\CalcSide,\CalcSide) -- cycle;  
\draw[dashed]
  (\CalcSide,\CalcSide,\CalcSide) -- (\CalcSide,\CalcSide,\BigSide);  

\draw[thick] 
  (szl) -- (syl) -- (sxl) -- (\BigSide,\CalcSide,\CalcSide) -- (\BigSide,\BigSide,\CalcSide) -- (\CalcSide,\BigSide,\CalcSide) -- cycle;

\node[label=above:$V$,fill,circle,inner sep=1.75pt] at (P) {};
\node[shift={(-0.5pt,0,0)}] at (C) {$C$};
\end{tikzpicture}

\end{document}

答案2

毫无疑问,还有更有效的方法,但在 3D 系统中使用形式的坐标(<x>,<y>,<z>)可能会使事情变得更容易。

\documentclass[tikz,border=10pt,multi]{standalone}

\begin{document}
\begin{tikzpicture}
  \draw (5,0,0) coordinate (x) |- (0,5,0) coordinate [midway] (h) coordinate (y) -- (0,5,5) coordinate (a) -- (0,0,5) coordinate (z) -- (5,0,5) edge (x) -- (5,5,5) coordinate (v) edge (h)
  -- (a)  ;
  \draw [dashed] (0,0,0) coordinate (o) edge (x) edge (y) -- (z);
  \node [circle, minimum size=5pt, inner sep=0pt, fill, label=135:V] at (v) {};
  \draw [->] (x) -- +(3pt,0,0) node [midway,above] {$x$};
  \draw [->] (y) -- +(0,3pt,0) node [midway,right] {$y$};
  \draw [->] (z) -- +(0,0,3pt) node [midway,above] {$z$};
  \draw (v) -- ++(0,0,-2) coordinate (d) -- ++(-2,0,0) coordinate (e) -- ++(0,0,2) |- ++(2,-2,0) coordinate [midway] (f) -- ++(0,0,-2) coordinate (g) -- (d);
  \draw [dashed] (e) -- ++(0,-2,0) coordinate (c) edge (f) -- (g);
  \node [label=45:C] at (c) {};
\end{tikzpicture}
\end{document}

立方体中的立方体

相关内容