我想改变这个等距图
\documentclass[tikz,border=1.618]{standalone}
\usetikzlibrary{3d,perspective}
\tikzset
{
abc/.style={fill=red,text=white,transform shape},
pics/my rectangle/.style={
code={
\draw (-2,-1.5) rectangle (2,1.5);
\node[abc=A] (-A) at (-1.3,0.5) {\small A};
\node[abc=B] (-B) at (1.3,0) {\small B};
\node[abc=C] (-C) at (-1.3,-0.6) {\small C};
}
},
}
\begin{document}
\begin{tikzpicture}[line join=round,isometric view,rotate around z=180]
\node[draw,canvas is xz plane at y=0,xscale=-1,transform shape] (reader) at (4,0) {{READER}};
\begin{scope}[shift={(-1.,0)}, rotate around z=-7]
\pic [canvas is yz plane at x=0] (1) {my rectangle};
\draw[canvas is xy plane at z=1.5] (0,-2) rectangle (-1,2);
\draw[canvas is xz plane at y=2] (0,-1.5) rectangle (-1,1.5);
\end{scope}
\draw[cyan,dashed,-latex] (reader.east) -- (1-A) node[pos=0.5,above, sloped, xslant=-0] {\small $d_1$};
\draw[cyan,dashed,-latex] (reader.east) -- (1-B) node[pos=0.5,above, sloped] {\small $d_3$};
\draw[cyan,dashed,-latex] (reader.east) -- (1-C) node[pos=0.7,above, sloped, yshift=-0.7mm, xslant=-0] {\small $d_2$};
\begin{scope}[shift={(0,-6cm)}, rotate around z=0]
\begin{scope}[shift={(-10,0)}, rotate around z=20] % ANGLE SIRVE para CAMBIAR pos de la caja
\pic [canvas is xy plane at z=-0.5,rotate=-90] (2) {my rectangle};
\draw[canvas is yz plane at x=1.5] (-2,-1.5) rectangle (2,-0.5);
\draw[canvas is xz plane at y=2] (-1.5,-1.5) rectangle (1.5,-0.5);
\end{scope}
\node[draw,fill=white,canvas is xz plane at y=0,xscale=-1,transform shape] (reader) at (4,0) {{READER}};
\draw[cyan,dashed,-latex] (reader.east) -- (2-A) node[pos=0.45,below, sloped] {\small$d_3$};
\draw[cyan,dashed,-latex] (reader.east) -- (2-B) node[pos=0.3,above, sloped] {\small$d_1$};
\draw[cyan,dashed,-latex] (reader.east) -- (2-C) node[pos=0.5,above, sloped] {\small$d_2$};
\end{scope}
\end{tikzpicture}
\end{document}
此代码是上一篇文章的解决方案如何制作一个旋转的长方体,改变相对于某个点的方向,并将物品保留在其上。顶部长方体代表一个纸板箱,其中一个面上装有物品 A、B 和 C,底部的盒子相同,但相对于固定的处于另一个位置Reader
。
我想表示一个类似的场景,同一个盒子在两个不同的位置,但是,将物品 A、B 和 C 的位置改为盒子的长窄面,就像这样
我尝试改变my rectangle
样式和帆布平面,但无法将物品放在盒子的窄边上。
答案1
在他的原始答案中,Juan Castaño 定义了一个pic
名为my rectangle
。在其中,他定义了一个矩形和 3 个节点 A、B 和 C。我并不完全了解这背后的原因。但是,您可以定义 2 个新的pic
并更改其内部代码以匹配您的绘图。
\tikzset
{
abc/.style={fill=red,text=white,transform shape},
pics/my rectangle 1/.style={
code={
\draw (-2,-1.5) rectangle (2,1.5);
\node[abc=A] (-A) at (-1.3,0.5) {\small A};
\node[abc=B] (-B) at (1.3,0) {\small B};
\node[abc=C] (-C) at (-1.3,-0.6) {\small C};
}
},
pics/my rectangle 2/.style={
code={
\draw (0,-2) rectangle (-1,2);
\node[abc=A,fill=green] (-A) at (-0.3,1.5) {\small A};
\node[abc=B,fill=green] (-B) at (-0.5,0) {\small B};
\node[abc=C,fill=green] (-C) at (-0.25,-0.6) {\small C};
}
},
pics/my rectangle 3/.style={
code={
\draw (0,-1.5) rectangle (-1,1.5);
\node[abc=A,fill=blue] (-A) at (-0.75,1) {\small A};
\node[abc=B,fill=blue] (-B) at (-0.25,0) {\small B};
\node[abc=C,fill=blue] (-C) at (-0.5,-0.6) {\small C};
}
},
}
\begin{document}
\begin{tikzpicture}[line join=round,isometric view,rotate around z=180]
\node[draw,canvas is xz plane at y=0,xscale=-1,transform shape] (reader) at (4,0) {{READER}};
\begin{scope}[shift={(-1.,0)}, rotate around z=-7] % ANGLE SIRVE para CAMBIAR pos de la caja]
\pic [canvas is yz plane at x=0] (1) {my rectangle 1};
\pic [canvas is xy plane at z=1.5] {my rectangle 2};
\pic [canvas is xz plane at y=2]{my rectangle 3};
\end{scope}
看看矩形路径是如何由不同的两个点定义的。对我来说这不是最好的方法,但这样做的好处是只需更改最少的代码行。总有另一种使用 Tikz 的方法。
您会注意到 A、B 和 C 在一个矩形中被翻转了。这是另一篇文章要讨论的问题。