-1

I'm using pst-solides3d for draw several images. However I have the same picture in a eps file, I would prefer to use a pstrick code.

The cube without some vertexs

  • Do this for me? Please let us know what you have tried so far and what are the problems you are facing. And welcome to TeX.SE. – Masroor Feb 7 '15 at 1:27
  • 1
    Your question leaves all the effort to our community, even typing the essentials of a TeX document such as \documentclass{}...\begin{document} etc. As it is, most of our users will be very reluctant to touch your question, and you are left to the mercy of our procrastination team who are very few in number and very picky about selecting questions. You can improve your question by adding a minimal working example (MWE) that more users can copy/paste onto their systems to work on. If no hero takes the challenge we might have to close your question. – cfr Feb 7 '15 at 2:09
  • I think it would look better without the dashed lines, using a gray colour instead of black to indicate that the lines are obscured. Dashed lines are the only way people had to indicate shading in documents printed in black and white, but I don't think anyone was ever happy about it. – Benjamin McKay Feb 7 '15 at 12:02
3

This is an attempt via tikz-3dplot. The boxes at corners are square box of 0.3cm in length. scope environments are used for ease of drawing the corners.

enter image description here

Code

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.