
答え1
3D で Tikz を使用するのは 2D の場合とほぼ同じですが、2D ではなく 3D 座標を使用する必要があります。
3D ボックスを描画する方法は次のとおりです (ご覧のとおり、2D 座標と 3D 座標を混在させることができます。その場合、2D 表現の z 座標は自動的にゼロであると見なされます)。
\beging{tikzpicture}
\draw (0,0) -- ++(8,0) -- ++(0,-4) -- ++(-8,0) -- ++(0,4) -- ++(0,0,-4) -- ++(8,0) -- ++(0,-4) -- ++(0,0,4) ++(0,4,0) -- ++(0,0,-4);
\draw[dashed] (0,-4) -- ++(0,0,-4) -- ++(8,0,0) ++(-8,0) -- ++(0,4);
\end{tikzpicture}
次はもう少し複雑な例(電磁波)です。
\begin{tikzpicture}[x={(-10:1cm)},y={(90:1cm)},z={(210:1cm)}]
% Axes
\draw[->] (-1,0,0) node[above] {$x$} -- (5,0,0);
\draw[->] (0,0,0) -- (0,2,0) node[above] {$y$};
\draw[->] (0,0,0) -- (0,0,2) node[left] {$z$};
% Waves
\draw[red,thick] plot[domain=0:4.5,samples=200] (\x,{cos(deg(pi*\x))},0);
\draw[blue,thick] plot[domain=0:4.5,samples=200] (\x,0,{cos(deg(pi*\x))});
% Arrows
\foreach \x in {0.1,0.3,...,4.4} {
\draw[red] (\x,0,0) -- (\x,{cos(deg(pi*\x))},0);
\draw[blue] (\x,0,0) -- (\x,0,{cos(deg(pi*\x))});
}
% Labels
\node[red, above right] at (0,1,0) {$\vec{\bm{E}}$};
\node[below, blue] at (0,0,1) {$\vec{\bm{H}}$};
\end{tikzpicture}