4

I can create two nodes in tikz-3dplot, and create a projection like view, like this :

projection node in tikz-3dplot

But how to create view like this(the right one- only those projection lines) ?

projection inside matrix

I have created the basic, I just need to draw those lines , here is the .tex file.

I have filled those blocks properly, now I need to draw those line , here I'm right now :

enter image description here

1 Answers1

1

My friend and me spent some Sunday time to help you ^^ We often use simple way, natural layer to draw, but in this case, \pgfdeclarelayer should be used. The red layer (named main) is drawn in bethween 2 blue layers (named Original layer and Result layer).

enter image description here

% Code: Le Huy Tien + Bui Quy
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[line join=round,transform shape]
\def\a{{{6,0,3,2},{5,3,1,0},{2,0,9,2},{4,1,6,1}}}
\def\b{{{-5,-1,2},{1,1,-9},{-4,8,-4}}}

\pgfdeclarelayer{Original layer}
\pgfdeclarelayer{Result layer}
\pgfsetlayers{Result layer,main,Original layer}

\begin{pgfonlayer}{Original layer}
\begin{scope}[yslant=-.25,local bounding box=Ori]
\fill[yellow] (2,1) rectangle +(2,2);
\draw[blue] (0,0) grid (4,4);
\draw[blue,very thick] (0,0) rectangle (4,4);
\foreach \i in {0,...,3}
\foreach \j in {0,...,3}{
\pgfmathsetmacro{\x}{int(\a[\i][\j])}
\path (\i+.5,\j+.5) node{\x};}
\path
(2,1) coordinate (A1)
(2,3) coordinate (A2)
(4,3) coordinate (A3)
(4,1) coordinate (A4);
\path (Ori.north) node[above=2mm]{Original};
\end{scope}
\end{pgfonlayer}

\begin{pgfonlayer}{Result layer}
\begin{scope}[yslant=-.25,shift={(5,2)},
local bounding box=Res]
\fill[yellow] (2,1) rectangle +(1,1);
\draw[blue] (0,0) grid (3,3);
\draw[blue,very thick] (0,0) rectangle (3,3);
\foreach \i in {0,...,2}
\foreach \j in {0,...,2}{
\pgfmathsetmacro{\x}{int(\b[\i][\j])}
\path (\i+.5,\j+.5) node{\x};}
\path
(2,1) coordinate (B1)
(2,2) coordinate (B2)
(3,2) coordinate (B3)
(3,1) coordinate (B4);
\path (Res.north) node[above=2mm]{Result};
\end{scope}
\end{pgfonlayer}

% on main layer
\foreach \i in {1,2,3,4}
\draw[red] (A\i)--(B\i);
\end{tikzpicture}
\end{document}
Black Mild
  • 17,569