在乳胶中绘制三维垂直矩形

在乳胶中绘制三维垂直矩形

这是我想要绘制的图:

在此处输入图片描述

我也想能够改变黄色。另外,灰色矩形上的箭头不是反转的,有人可以帮我这样做吗?

答案1

在此处输入图片描述

\documentclass[border=20, tikz]{standalone}

\usetikzlibrary{3d}

\begin{document}
    \begin{tikzpicture}[>=latex]
        \fill [canvas is zx plane at y=0, gray] (-2, 0) rectangle (0, 3);
        \fill [yellow] (0, -1) rectangle (3, 1);
        \fill [canvas is zx plane at y=0, gray] (0, 0) rectangle (2, 3);
        
        \draw [canvas is zx plane at y=0, ->, thick] (0, 0) -- (2, 0) node [left] {\(b\)};
        \draw [canvas is zx plane at y=0, ->, thick] (2, 3) -- (-2, 3) node [right] {\(b\)};
        \draw [->, thick] (0, 0) -- (0, 1) node [above] {\(a\)};
        \draw [->, thick] (3, -1) -- (3, 1) node [above] {\(a\)};
        \draw [thick] (0, -1) -- ++ (0, 0.23);
    \end{tikzpicture}
\end{document}

要改变黄色飞机的颜色,只需将其更改yellow为您想要的颜色即可。

答案2

如果您想使用一些不透明度,这里有一个解决方案:

在乳胶中绘制三维垂直矩形

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
    \begin{tikzpicture}[
        plana/.style={pink,opacity=0.8},
        planb/.style={purple!50,opacity=0.8},
        arr/.style={-Stealth, line width=2pt}
        ]
        \def\L{6} \def\H{4} \def\S{1}
        \fill[plana] (0,0) rectangle (\L,-\H/2);
        \draw[line width=2pt] (0,-\H/2) -- (0,0);
        \fill[planb] (-\S,-\S) --++ (\L,0) --++ (2*\S,2*\S) --++ (-\L,0) -- cycle;
        \draw[arr] (\S,\S) --++ (-2*\S,-2*\S) node [pos=1.1] {$b$};
        \fill[plana] (0,0) rectangle (\L,\H/2);
        \draw[arr] (-\S+\L,-\S) --++ (2*\S,2*\S) node [pos=1.1] {$b$};
        \draw[arr] (\L,-\H/2) --++ (0,\H) node [pos=1.1] {$a$};
        \draw[arr] (0,0) --++ (0,\H/2) node [pos=1.2] {$a$};
    \end{tikzpicture}
\end{document}

相关内容