6

I need to make a picture of some 3D boxes (i.e., parallelepipeds) that intersect themselves in some complicated ways, so I tried pst-solides3d.

Here's the minimal working example: A long and thin blue box should pierce a flat yellow box at its center.

\documentclass{standalone}
\usepackage{pstricks,pst-solides3d}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
    \psset{viewpoint=20 25 15,Decran=50,solidmemory}
    \axesIIID(0,0,0)(2,2,2)
    \psSolid[name=longbox,
        object=parallelepiped,
        a=3,b=.2,c=.2,
        fillcolor=blue](.5,.5,.5)
    \psSolid[
        name=flatbox,
        object=parallelepiped,
        a=.25,b=2,c=2,
        fillcolor=yellow](.5,.5,.5)
    \psSolid[object=fusion,
        action=draw,
        base=flatbox longbox]
        (0,0,0)
    \composeSolid
\end{pspicture}
\end{document}

The output is very strange: A piece of the thin box became yellow. It seems that the package is unable to determine which pieces of surfaces are in front.

output

With the option action=draw**, the result is even worse:

enter image description here

Am I doing something wrong?

4

You need more than the six polygon shapes of the blue cube to draw hidden surfaces. And, of course, all objects must be calculated with action=none except of the last one:

\documentclass{standalone}
\usepackage{pst-solides3d}
\begin{document}
\begin{pspicture}(-3,-2)(3,3)
    \psset{viewpoint=20 25 15,Decran=50,solidmemory,action=none}
    \axesIIID(0,0,0)(2,2,2)
    \multido{\rA=0.0+0.3,\iA=0+1}{11}{%
      \psSolid[name=l\iA, object=parallelepiped,a=0.3,b=.2,c=.2,
          fillcolor=blue](-0.75 \rA\space add .5 .5)}
    \psSolid[
        name=flatbox,
        object=parallelepiped, a=.25,b=2,c=2,fillcolor=yellow](.5,.5,.5)
  \def\List{l0 }
  \psforeach{\iA}{1,2,..,10}{\xdef\List{\List\space l\iA\space }}
    \psSolid[object=fusion,action=draw**,base=flatbox \List]
\end{pspicture}

\end{document}

enter image description here

  • Thanks for your answer. It's now clear that the package is less powerful than I expected, so boxes need to be partioned manually. – Jairo Bochi Jul 19 '14 at 21:44
  • it is simple to define a new object, which does this itself. – user2478 Jul 20 '14 at 5:21

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.