我绘制了 xyz 轴和立方体,并在其中绘制了一些额外的线条,使用如下方法:
\begin{tikzpicture}[x=0.4cm,y=0.4cm,z=0.24cm]
\draw[->] (xyz cs:x=0) -- (xyz cs:x=20) node[above] {$r_1$};
\draw[->] (xyz cs:y=0) -- (xyz cs:y=20) node[right] {$r_3$};
\draw[->] (xyz cs:z=0) -- (xyz cs:z=-16) node[below] {$r_2$};
\draw[dashed, gray, ultra thin] (xyz cs:x=0) -- (xyz cs:x=-8);
\draw[dashed, gray, ultra thin] (xyz cs:y=0) -- (xyz cs:y=-8);
\draw[dashed, gray, ultra thin] (xyz cs:z=0) -- (xyz cs:z=8);
\draw (xyz cs: x=10, y=0, z=0) -- (xyz cs: x=10, y=0, z=-8);
\draw (xyz cs: x=10, y=0, z=-8) -- (xyz cs: x=0, y=0, z=-8);
\draw (xyz cs: x=10, y=0, z=0) -- (xyz cs: x=10, y=10, z=0);
\draw (xyz cs: x=0, y=0, z=-8) -- (xyz cs: x=0 ,y=10 ,z=-8);
\draw (xyz cs: x=10, y=0, z=-8) -- (xyz cs: x=10 ,y=10 ,z=-8);
\draw (xyz cs: x=0, y=10, z=0) -- (xyz cs: x=0 ,y=10,z=-8);
\draw (xyz cs: x=0, y=10, z=0) -- (xyz cs: x=10,y=10,z=0);
\draw (xyz cs: x=0, y=10, z=-8) -- (xyz cs: x=10,y=10,z=-8);
\draw (xyz cs: x=10, y=10, z=-8) -- (xyz cs: x=10,y=10,z=0);
% inner line:
\draw [dashed, blue, line width=0.7mm] (xyz cs: x=5, y=5, z=0) -- (xyz cs: x=5, y=5, z=-8);
\node[blue,fill,circle,inner sep=1.5pt] at (5,5,0) {};
\node[blue,fill,circle,inner sep=1.5pt] at (5,5,-8) {};
\draw [dashed, thin] (xyz cs:x=5,y=0,z=-8) -- (xyz cs:x=5,y=10,z=-8);
\draw [dashed, thin] (xyz cs:x=0,y=5,z=-8) -- (xyz cs:x=10,y=5,z=-8);
\draw [dashed, thin] (xyz cs:x=5,y=0,z=0) -- (xyz cs:x=5,y=10,z=0);
\draw [dashed, thin] (xyz cs:x=0,y=5,z=0) -- (xyz cs:x=10,y=5,z=0);
\draw[thick] (xyz cs: x=5,y=0.3,z=0) -- (xyz cs: x=5,y=-0.3,z=0) node[below=3pt] {$\mu_1$};
\draw[thick] (xyz cs: x=-0.3,y=5,z=0) -- (xyz cs: x=0.3,y=5,z=0) node[left=6pt] {$\mu_3$};
\end{tikzpicture}
我知道这可能非常业余,但可以做得更容易——这是我第一次使用它,所以我仍处于学习过程中:)
是否可以将整个物体绕 y 轴旋转(标记为 r3)?最好只使用额外的命令,而不是编辑整个代码。因为现在有些线(几乎)重合,扭曲了 3D 效果。
答案1
您可以将rotate around y=<angle>
键添加到tikzpicture
选项中。另一种可能性是尝试使用 x、y、z 的单位向量,尽管这不太方便。
xyz
注意:您可以使用 在坐标系中指定坐标(x,y,z)
,而不必使用xyz cs: ...
。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[x=0.4cm,y=0.4cm,z=0.24cm,rotate around y=10]
% \begin{tikzpicture}[x={(0.3cm,0cm)},y={(0cm,0.3cm)},z={(0.2cm,0.2cm)}] % this is just an example showing how to set unit vectors, rather than lengths. It doesn't reproduce the rotate around y example
\draw[->] (xyz cs:x=0) -- (xyz cs:x=20) node[above] {$r_1$};
\draw[->] (xyz cs:y=0) -- (xyz cs:y=20) node[right] {$r_3$};
\draw[->] (xyz cs:z=0) -- (xyz cs:z=-16) node[below] {$r_2$};
\draw[dashed, gray, ultra thin] (xyz cs:x=0) -- (xyz cs:x=-8);
\draw[dashed, gray, ultra thin] (xyz cs:y=0) -- (xyz cs:y=-8);
\draw[dashed, gray, ultra thin] (xyz cs:z=0) -- (xyz cs:z=8);
\draw (xyz cs: x=10, y=0, z=0) -- (xyz cs: x=10, y=0, z=-8);
\draw (xyz cs: x=10, y=0, z=-8) -- (xyz cs: x=0, y=0, z=-8);
\draw (xyz cs: x=10, y=0, z=0) -- (xyz cs: x=10, y=10, z=0);
\draw (xyz cs: x=0, y=0, z=-8) -- (xyz cs: x=0 ,y=10 ,z=-8);
\draw (xyz cs: x=10, y=0, z=-8) -- (xyz cs: x=10 ,y=10 ,z=-8);
\draw (xyz cs: x=0, y=10, z=0) -- (xyz cs: x=0 ,y=10,z=-8);
\draw (xyz cs: x=0, y=10, z=0) -- (xyz cs: x=10,y=10,z=0);
\draw (xyz cs: x=0, y=10, z=-8) -- (xyz cs: x=10,y=10,z=-8);
\draw (xyz cs: x=10, y=10, z=-8) -- (xyz cs: x=10,y=10,z=0);
% inner line:
\draw [dashed, blue, line width=0.7mm] (xyz cs: x=5, y=5, z=0) -- (xyz cs: x=5, y=5, z=-8);
\node[blue,fill,circle,inner sep=1.5pt] at (5,5,0) {};
\node[blue,fill,circle,inner sep=1.5pt] at (5,5,-8) {};
\draw [dashed, thin] (xyz cs:x=5,y=0,z=-8) -- (xyz cs:x=5,y=10,z=-8);
\draw [dashed, thin] (xyz cs:x=0,y=5,z=-8) -- (xyz cs:x=10,y=5,z=-8);
\draw [dashed, thin] (xyz cs:x=5,y=0,z=0) -- (xyz cs:x=5,y=10,z=0);
\draw [dashed, thin] (xyz cs:x=0,y=5,z=0) -- (xyz cs:x=10,y=5,z=0);
\draw[thick] (xyz cs: x=5,y=0.3,z=0) -- (xyz cs: x=5,y=-0.3,z=0) node[below=3pt] {$\mu_1$};
\draw[thick] (xyz cs: x=-0.3,y=5,z=0) -- (xyz cs: x=0.3,y=5,z=0) node[left=6pt] {$\mu_3$};
\end{tikzpicture}
\end{document}