4

I just got to know tikz used to draw images. I check the manual because I want to draw a image like I download from https://developer.apple.com/library/ios/documentation/Performance/Conceptual/vImage/ConvolutionOperations/ConvolutionOperations.html

I am not sure whether tikz can do this since I found that the number in the grids somehow has be rotated also. That is , the number seems rotated which is consistent to the planes.

I know draw some lines but I am not sure how to write the text like this.

Any suggestion would be appreciate.

user18481
  • 151
  • Maybe http://tex.stackexchange.com/questions/254010/placing-text-on-face-of-3d-cube or http://tex.stackexchange.com/questions/302539/putting-labels-on-a-cube-with-perspective is helpfull – samcarter_is_at_topanswers.xyz May 20 '16 at 19:30
  • Also see http://tex.stackexchange.com/questions/212699/text-projection-onto-plane-in-3d-pgf-plots/212811?s=1|0.8804#212811 and http://tex.stackexchange.com/questions/141274/sloped-text-along-slanted-paths-in-tikz/141525?s=5|0.5701#141525 – John Kormylo May 20 '16 at 19:54
  • Also http://tex.stackexchange.com/questions/170244/how-to-compute-xslant-and-yslant/170255?s=1|4.9050#170255 – John Kormylo May 20 '16 at 20:02
  • TikZ really isn't the best choice - or the easiest - for 3D. Unless you are just super comfortable with TikZ and not at all with the alternatives, it would be worth your while considering one of the latter. – cfr May 21 '16 at 00:40

1 Answers1

7

Here is a beginning of solution, I filled the table with any values.

you must use the commands canvas to draw on inclined plane and use transform shape for as bow node

\documentclass{scrartcl}
 \usepackage{tikz}
 \usetikzlibrary{arrows,3d,matrix}

 % see the explanation below
 \makeatletter
 \tikzoption{canvas is xy plane at z}[]{%
   \def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
   \def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
   \def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
   \tikz@canvas@is@plane
 }
 \makeatother 

\begin{document}
\begin{tikzpicture}
 [x={(0.866cm,0.5cm)}, y={(-0.866cm,0.5cm)}, z={(0cm,1cm)}, scale=0.8]




    \begin{scope}[canvas is xz plane at y=0,transform shape]
      %\draw[blue] (0,0) -- (10,0)--(10,10)--(0,10)--cycle;
      \foreach \ii [count = \xi] in {1,2,3,...,8}{
            \foreach \jj  [count = \yi]in {1,2,3,...,8}{
            \pgfmathsetmacro{\nn}{int(\xi+8*\yi-8)}
      \node[red,draw,minimum size=1cm] (n\nn-1) at (\ii,-\jj) {\nn};
      }
      }

      \end{scope}

        \begin{scope}[canvas is xz plane at y=-7.3,transform shape]
      \foreach \ii [count = \xi] in {1,2,3}{
            \foreach \jj  [count = \yi]in {1,2,3}{
            \pgfmathsetmacro{\nn}{int(\xi+3*\yi-3)}
      \node[blue,draw,minimum size=1cm] (n\nn-2) at (\ii,-\jj) {\nn};
      }
      }
      \end{scope} 

      \begin{scope}[canvas is xz plane at y=-11.2,transform shape]
      \foreach \ii [count = \xi] in {1,2,3,...,8}{
            \foreach \jj  [count = \yi]in {1,2,3,...,8}{
            \pgfmathsetmacro{\nn}{int(\xi+8*\yi-8)}
      \node[green,draw,minimum size=1cm] (n\nn-3) at (\ii,-\jj) {\nn};
      }
      }
      \end{scope} 

      \draw[fill=red!50,opacity=0.3] (n10-1.north east) -- (n5-2.north east) --(n10-3.north east)
      --(n10-3.north west)-- (n5-2.north west) --  (n10-1.north west)  ;
      \draw[fill=red!50,opacity=0.3] (n10-1.south east) -- (n5-2.south east) --(n10-3.south east)
      --(n10-3.south west)-- (n5-2.south west)-- (n10-1.south west)  ;    
      \draw[fill=red!50,opacity=0.3] (n10-1.north east) -- (n5-2.north east) --(n10-3.north east)
      --(n10-3.south east)-- (n5-2.south east)-- (n10-1.south east)  ;

      \draw[fill=red!50,opacity=0.3] (n10-3.north west)-- (n5-2.north west) --  (n10-1.north west) -- (n10-1.south west)-- (n5-2.south west)   --(n10-3.south west) ;        

  \end{tikzpicture}

  \end{document}

enter image description here

rpapa
  • 12,350