5

In order to create a gif I did the following:

\documentclass[border=0pt]{standalone}
\usepackage{pst-solides3d}
\begin{document}
\newcommand{\viewpoint}{25 15 5}
\newcommand{\axis}{\axesIIID(0,0,0)(4.5,4,4)}
\psset{unit=1}
\psset{viewpoint=\viewpoint}
\psset{action=draw*,incolor=green!20!white, linewidth=0.5pt}

\multido{\i=1+2}{3}{
\begin{pspicture}(-5.3,-2.5)(7,8)
 \axis
 \multido{\r=0+1.5}{3}{
 \psSolid[object=face, base=3 3 3 0 0 0 0 3](0,0,\r)}
 \multido{\r=0.75+1.5}{2}{
 \psSolid[object=face, base=3 3 3 0 0 0 0 3](0,0,\r)}
 \psset{incolor=red}
 \multido{\r=0.375+0.75}{\i}{
 \psSolid[object=face, base=3 3 3 0 0 0 0 3](0,0,\r)}
\end{pspicture}}
\end{document}

example

Is it possible to draw the green squares first and then draw the red between them?

4

It is a question of when you draw the planes. It can also be done with pst-3dplot:

\documentclass[border=10pt]{standalone}
\usepackage{pst-solides3d}
\begin{document}
\psset{viewpoint=25 15 5, linewidth=0.5pt}

\multido{\i=2+2}{4}{%
  \begin{pspicture}(-5.3,-2.5)(7,8)
    \axesIIID(0,0,0)(4.5,4,4)
    \multido{\r=0.0+-0.375,\iA=0+1}{9}{%
      \ifodd\iA
        \ifnum\iA<\i
          \psSolid[object=plan,definition=equation,
            fillstyle=solid,fillcolor=red,
            args={[0 0 1 \r]},base=-1.5 1.5 -1.5 1.5]
        \fi
      \else
        \psSolid[object=plan,definition=equation,
          fillstyle=solid,fillcolor=green!20!white,
          args={[0 0 1 \r]},base=-1.5 1.5 -1.5 1.5]
      \fi}
    \end{pspicture}%
}
\end{document}

enter image description here

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.