我可以node
在中创建两个 s tikz-3dplot
,并创建一个类似视图的投影,如下所示:
但是如何创建像这样的视图(正确的视图 - 只有那些投影线)?
我已经创建了基础,我只需要画出那些线条,这里是.tex
文件。
我已经正确填充了这些块,现在我需要画出这些线,我现在在这里:
答案1
我和朋友花了周日的时间来帮助你 ^^ 我们经常使用简单的方法,自然的图层来绘制,但在这种情况下,应该使用。红色图层(名为 main)绘制在 2 个蓝色图层(名为和)\pgfdeclarelayer
之间。Original layer
Result layer
% 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}