How can I draw a transparent cube in 3D perspective?

\documentclass{article}
\usepackage{pst-solides3d}    
\begin{document}

\psset{viewpoint=10 60 15 rtp2xyz,Decran=5}
\begin{pspicture}[solidmemory](-5,-5)(6,12)
\psSolid[object=point,args=10 -36 0,name=L]
\psSolid[object=point,args=-36 10 0,name=R]
\psSolid[object=line,linecolor=blue,linestyle=dashed,linewidth=2pt,args=R L]
\psSolid[object=parallelepiped,a=6,b=3,c=3,RotZ=30,name=Cube,action=draw*](0 0 2)
\multido{\iA=0+1}{8}{%
  \psSolid[object=point,definition=solidgetsommet,args=Cube \iA,name=C\iA]}
\multido{\iA=0+1}{8}{%
  \psSolid[object=line,linecolor=blue!40,linestyle=dotted,args=L C\iA]
  \psSolid[object=line,linecolor=blue!40,linestyle=dotted,args=R C\iA]}
\psSolid[object=parallelepiped,a=6,b=3,c=3,RotZ=30,name=Cube,action=draw](0 0 2)
\end{pspicture}

\end{document}

enter image description here


Unfortunately, I don't know pstricks, but here's A TikZ solution:

Code

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{calc,intersections}

\begin{document}

\begin{tikzpicture}
\coordinate (V1) at (-7,1);
\coordinate (V2) at (5,1);

\fill (V1) circle (0.05) node[left] {V1};
\fill (V2) circle (0.05) node[right] {V2};

\pgfmathsetmacro{\cubelength}{3}

\coordinate (A) at (0,0);
\coordinate (B) at ($(A)!\cubelength cm!(V2)$);
\coordinate (D) at ($(A)!\cubelength cm!(V1)$);

\path[name path=BV1] (B) -- (V1);
\path[name path=DV2] (D) -- (V2);

\path[name intersections={of=BV1 and DV2}] (intersection-1);
\coordinate (C) at (intersection-1);

\coordinate (E) at (0,3);

\path[name path=Bup] (B) -- ++(0,\cubelength);
\path[name path=Dup] (D) -- ++(0,\cubelength);
\path[name path=EV1] (E) -- (V1);
\path[name path=EV2] (E) -- (V2);

\path[name intersections={of=Bup and EV2}] (intersection-1);
\coordinate (F) at (intersection-1);

\path[name intersections={of=Dup and EV1}] (intersection-1);
\coordinate (H) at (intersection-1);

\path[name path=FV1] (F) -- (V1);
\path[name path=HV2] (H) -- (V2);

\path[name intersections={of=FV1 and HV2}] (intersection-1);
\coordinate (G) at (intersection-1);

\foreach \x in {A,B,C,D,E,F,G,H} \fill (\x) circle (0.05) node[below right,circle] {\x};

\foreach \s\e in {A/B,D/A,A/E,B/F,D/H,E/F,F/G,G/H,H/E} \draw (\s) -- (\e);

\foreach \s\e in {B/C,C/D,C/G} \draw[densely dashed] (\s) -- (\e);

\foreach \p in {C,D,G,H} \draw[dotted] (\p) -- (V1);

\foreach \p in {B,C,F,G} \draw[dotted] (\p) -- (V2);

\path[name path=V1V2] (V1) -- (V2);

\draw[name intersections={of={Bup and V1V2},name=R}] (V2) -- (R-1);

\draw[name intersections={of={Dup and V1V2},name=L}] (V1) -- (L-1);

\draw[dotted] (L-1) -- (R-1);

\end{tikzpicture}

\end{document}

Output

enter image description here


Tikz is a very powerful package with many examples available. Have a look at this example:

enter image description here

Is this something like what you are after?

Tags:

3D

Pstricks