具有矩阵地板的 3D 超矩形

具有矩阵地板的 3D 超矩形

得到我所说的“地板”是可以的。

\begin{tikzpicture}
\matrix[matrix of math nodes,nodes in empty cells,
nodes={minimum size=2.5em,outer sep=0pt,anchor=center,draw,loosely dashed},
row sep=-\pgflinewidth,column sep=-\pgflinewidth
] (mat) {
    |[fill=gray!15!]|-2,4 & -2,3 & -2 \\
    -2,5 & -2,6 & -1,9\\
    -0,8 & -0,5  & -1,5 \\
};
\draw[thick] (mat-1-1.north west) rectangle (mat-3-3.south east); 
\end{tikzpicture}

但由于我无法旋转 tikz \matrix,因此我无法找到任何方法来重现此绘图。

答案1

如果尺寸固定(3x3x3),您可以执行以下操作。否则,您需要调整代码,但这并不难。

我制作了一个程序pic,它获取一个数字列表(来自一个矩形),然后绘制(以 3d 形式)网格并将其放入这些数字中。

这是代码:

\documentclass[border=2mm]{standalone}
\usepackage    {siunitx}
\usepackage    {tikz}
\usetikzlibrary{3d}    % for 'canvas is...' options
\sisetup       {output-decimal-marker = {,}}

\tikzset
{%
  pics/matrix/.style={
    /tikz/transform shape,
    code={%
      \fill (0,0) rectangle (4.5,3);
      \draw (0,0) grid[xstep=1.5] (4.5,3);
      \foreach[count=\j]\i in {#1}
      {
        \pgfmathsetmacro\x{1.5*Mod(\j-1,3)+0.75}
        \pgfmathsetmacro\y{div(\j-1,3)+0.5}
        \node[fill opacity=1] at (\x,\y) {\num{\i}};
      }
    }},
  axonometric/.style={y={(0.2456cm,0.6747cm)},x={(0.9694cm,-0.1709cm)},z={(0cm,0.7180cm)}},
  my orange/.style={fill=orange,fill opacity=#1}
}

\begin{document}
\begin{tikzpicture}[axonometric]
  \draw[dashed] (0  ,3,0) --++ (0,0,6.4);
  \draw[dashed] (4.5,3,0) --++ (0,0,6.4);
  \pic[my orange=0.45,canvas is xy plane at z=0]   {matrix={0.3,-1.5,2.3,0.4,-0.2,-0.3,-2,-0.8,-0.4}};
  \pic[my orange=0.30,canvas is xy plane at z=3.2] {matrix={-2.4,-2.3,-2,-2.5,-2.6,-1.9,-0.8,-0.5,-1.5}}; % not the original numbers
  \pic[my orange=0.15,canvas is xy plane at z=6.4] {matrix={-2.4,-2.3,-2,-2.5,-2.6,-1.9,-0.8,-0.5,-1.5}}; % not the original numbers
  \draw (0  ,0,0) --++ (0,0,6.4);
  \draw (4.5,0,0) --++ (0,0,6.4);
  \node[canvas is xy plane at z=0]   at (4.5,0.5) [right] {$\Rightarrow$ Sortie};
  \node[canvas is xy plane at z=6.4] at (0,1.5)   [left]  {Entrée $\Rightarrow$};
\end{tikzpicture}
\end{document}

还有图片: 在此处输入图片描述

相关内容