我使用 pst-solides3d 绘制多幅图像。但是我在 eps 文件中有相同的图片,我更喜欢使用 pstrick 代码。
答案1
这是通过的尝试tikz-3dplot
。角落处的框是长度为0.3cm的方框。scope environments
用于方便绘制角落。
代码
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{shapes,calc,positioning}
\tdplotsetmaincoords{70}{145}
\begin{document}
\begin{tikzpicture}[scale=2, tdplot_main_coords,axis/.style={->,dashed}]
% -- remove these 3 lines if no axis is preferred
%\draw[axis] (0, 0, 0) -- (2.5, 0, 0) node [right] {$X$};
%\draw[axis] (0, 0, 0) -- (0, 2.5, 0) node [above] {$Y$};
%\draw[axis] (0, 0, 0) -- (0, 0, 2.5) node [above] {$Z$};
\coordinate (d1) at (0,0,2){};
\coordinate (d2) at (2,0,2){};
\coordinate (d3) at (2,2,0){};
\coordinate (d4) at (0,2,0){};
\coordinate (d5) at (0,0,0){};
\coordinate (d6) at (2,0,0){};
\coordinate (d7) at (0,2,2){};
\coordinate (d8) at (2,2,2){};
% fill gray color with opacity
\fill[gray!80,opacity=0.2] (d2) -- (d6) -- (d3)-- (d8)--cycle;
\fill[gray!80,opacity=0.2] (d1) -- (d5) -- (d6)-- (d2)--cycle;
\fill[gray!80,opacity=0.2] (d1) -- (d5) -- (d4)-- (d7)--cycle;
\fill[gray!80,opacity=0.8] (d6) -- (d3) -- (d4)-- (d5)--cycle;
\fill[gray!80,opacity=0.2] (d2) -- (d6) -- (d3)-- (d8)--cycle;
\fill[gray!80,opacity=0.1] (d1) -- (d2) -- (d6)-- (d5)--cycle;
\fill[gray!80,opacity=0.1] (d1) -- (d2) -- (d8)-- (d7)--cycle;
\fill[gray!80,opacity=0.1] (d3) -- (d4) -- (d7)-- (d8)--cycle;
% draw frames
\draw (d1)--(d2)--(d8)--(d7)--(d1);
\draw (d3)--(d4)--(d7)--(d8)--(d3);
\draw (d2)--(d6)--(d3);
\draw [dashed] (d1)--(d5)--(d4);
\draw [dashed] (d5)--(d6);
% 4 small boxes at corners
\begin{scope}[shift={(0,0,0)}] % box at the origin
\coordinate (d51) at (0.3,0,0){};
\coordinate (d52) at (0,0.3,0){};
\coordinate (d53) at (0,0,0.3){};
\coordinate (d54) at (0.3,0.3,0){};
\coordinate (d55) at (0,0.3,0.3){};
\coordinate (d56) at (0.3,0,0.3){};
\coordinate (d57) at (0.3,0.3,0.3){};
\fill[gray!30](d53) -- (d56) -- (d57) -- (d55) -- cycle;
\fill[gray!30](d51) -- (d56) -- (d57) -- (d54) -- cycle;
\fill[gray!30](d54) -- (d52) -- (d55) -- (d57) -- cycle;
\draw[dashed] (d53) -- (d56) -- (d57) -- (d55) -- (d53);
\draw[dashed] (d51) -- (d56) (d51)--(d54)--(d57) (d54)--(d52)--(d55);
\end{scope}
\begin{scope}[shift={(1.7,0,1.7)}] % the left corner
\coordinate (d51) at (0.3,0,0){};
\coordinate (d52) at (0,0.3,0){};
\coordinate (d53) at (0,0,0.3){};
\coordinate (d54) at (0.3,0.3,0){};
\coordinate (d55) at (0,0.3,0.3){};
\coordinate (d56) at (0.3,0,0.3){};
\coordinate (d57) at (0.3,0.3,0.3){};
\draw[white,line width=5pt,shorten < =-2pt] (d53)--(d56) (d56)--(d51) (d56)--(d57);
\fill[white] (d53) -- (d56) -- (d57)-- (d55) -- cycle;
\fill[white] (d51) -- (d56) -- (d57)-- (d54) -- cycle;
\fill[gray!40](d55) -- (d53) --++(0,0,-0.3) -- (d52)--cycle;
\fill[gray!40](d54) -- (d52) -- (d55)-- (d57) -- cycle;
\fill[gray!40](d52) -- (d54) -- (d51)-- ++(-0.3,0,0)--cycle;
\draw[] (d51) -- (d54) -- (d57)-- (d55) -- (d53)--++(0,0,-0.3) --(d51);
\draw[dashed] (d54) -- (d52) -- (d55) (d52) --++(0,-0.3,0);
\draw (d8)--(d57);
\end{scope}
\begin{scope}[shift={(0,1.7,1.7)}] % at right corner
\coordinate (d51) at (0.3,0,0){};
\coordinate (d52) at (0,0.3,0){};
\coordinate (d53) at (0,0,0.3){};
\coordinate (d54) at (0.3,0.3,0){};
\coordinate (d55) at (0,0.3,0.3){};
\coordinate (d56) at (0.3,0,0.3){};
\coordinate (d57) at (0.3,0.3,0.3){};
\draw[line width=2pt,white,shorten < =-2pt] (d55)--(d53) (d55)--(d57)(d55)--(d52);
\fill[white] (d53) -- (d55) -- (d52) -- ++(0,-0.3,0) -- cycle;
\fill[white] (d54) -- (d57) -- (d55) -- ++(0,0,-0.3)--cycle;
\fill[gray!40](d56) -- (d57) -- (d54) --(d51)--cycle;
\fill[gray!40](d52) -- (d54) -- (d51) -- ++ (-0.3,0,0)--cycle;
\fill[gray!40](d51) -- (d56) -- (d53) -- ++ (0,0,-0.3)--cycle;
\draw[] (d53) -- (d56) -- (d57) --(d54) --(d52) --++(0,-0.3,0) --(d53);
\draw[dashed] (d56) -- (d51) (d51) --++(-0.3,0,0) (d51)--(d54);
\draw (d8)--(d57);
\end{scope}
\begin{scope}[shift={(1.7,1.7,0)}] % at front corner
\coordinate (d51) at (0.3,0,0){};
\coordinate (d52) at (0,0.3,0){};
\coordinate (d53) at (0,0,0.3){};
\coordinate (d54) at (0.3,0.3,0){};
\coordinate (d55) at (0,0.3,0.3){};
\coordinate (d56) at (0.3,0,0.3){};
\coordinate (d57) at (0.3,0.3,0.3){};
\draw[line width=2pt,white] (d54)--(d51) (d54)--(d57)(d54)--(d52);
\fill[white] (d57) -- (d55) -- (d52) -- ++(0.3,0,0) -- cycle;
\fill[white] (d54) -- (d57) -- (d56) -- (d51) --cycle;
\fill[gray!40](d53) -- (d56) -- (d51) -- ++(-0.3,0,0)--cycle;
\fill[gray!40](d53) -- (d55) -- (d52) -- ++ (0,-0.3,0)--cycle;
\fill[gray!80](d53) -- (d55) -- (d57) -- (d56) --cycle;
\draw[] (d51) -- (d56) -- (d57) -- (d55) --(d52)--++(0,-0.3,0)--(d51)
(d53) --++(0,0,-0.3) --(d51) (d52) --++(0,-0.3,0);
\draw[dashed] (d53) -- (d55) (d56) --(d53) ;
\draw (d8)--(d57);
\end{scope}
--- labels for vertices
\foreach \i in {1,2,...,8}
{
\draw[] (d\i)
node[above right] {\tiny \i};
}
\end{tikzpicture}
\end{document}