1

Based on Herbert's answer to this question, I made the following:

\documentclass[pstricks, border=0pt]{standalone}
\usepackage{pst-solides3d}

\begin{document}

\psset{unit=1}
\psset{viewpoint=30 7 6}
\psset{action=draw*,incolor=green!20!white, fillcolor=green!20!white, linewidth=0.5pt, opacity=1}

\multido{\iB=2+2}{1}{%
  \begin{pspicture}(-0.8,-0.8)(2,2)
    \multido{\r=0.0+0.5,\iC=0+1}{3}{%
      \ifodd\iC
        \ifnum\iC<\iB
          \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
        \fi
      \else
        \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
      \fi}
    \end{pspicture}%
}

\multido{\iB=2+2}{2}{%
  \begin{pspicture}(-0.8,-0.8)(2,2)
    \multido{\r=0.0+0.25,\iC=0+1}{5}{%
      \ifodd\iC
        \ifnum\iC<\iB
          \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
        \fi
      \else
        \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
      \fi}
    \end{pspicture}%
}

\multido{\iB=2+2}{4}{%
  \begin{pspicture}(-0.8,-0.8)(2,2)
    \multido{\r=0.0+0.125,\iC=0+1}{9}{%
      \ifodd\iC
        \ifnum\iC<\iB
          \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
        \fi
      \else
        \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
      \fi}
    \end{pspicture}%
}

\multido{\iB=2+2}{8}{%
  \begin{pspicture}(-0.8,-0.8)(2,2)
    \multido{\r=0.0+0.0625,\iC=0+1}{17}{%
      \ifodd\iC
        \ifnum\iC<\iB
          \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
        \fi
      \else
        \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
      \fi}
    \end{pspicture}%
}

\end{document}

Now I would like to put the four multido's in another multido:

\documentclass[pstricks, border=0pt]{standalone}
\usepackage{pst-solides3d}

\begin{document}
\psset{unit=1}
\psset{viewpoint=30 7 6}
\psset{action=draw*,incolor=green!20!white, fillcolor=green!20!white, linewidth=0.5pt, opacity=1}

\multido{\iA=1+1}{4}{
 \multido{\iB=2+2}{2^(\iA-1)}{%
  \begin{pspicture}(-0.8,-0.8)(2,2)
    \multido{\r=0.0+2^(-\iA),\iC=0+1}{2^(\iA)+1}{%
      \ifodd\iC
        \ifnum\iC<\iB
          \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
        \fi
      \else
        \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
      \fi}
    \end{pspicture}%
 }
}
\end{document}

How can I make latex calculate 2^(\iA-1),2^(-\iA) and 2^(\iA)+1?

  • I do not really understand what exactly do you want to achieve. Please insert your additional code into your example so that I can see what does not work. – user2478 Aug 6 '17 at 5:57
1
\documentclass[pstricks, border=0pt]{standalone}
\usepackage{pst-solides3d}

\begin{document}
\psset{viewpoint=30 7 6, action=draw*,incolor=green!20!white, 
       fillcolor=green!20!white, 
       linewidth=0.5pt,  opacity=1}
\newcount\cntA  \cntA=1 
\newcount\cntB  \cntB=2
\pstFPdiv\rcntB{1}{\the\cntB}

\multido{\iA=1+1}{4}{%
  \multido{\iB=2+2}{\the\cntA}{%
    \begin{pspicture}(-0.8,-0.8)(2,2)
    \multido{\r=0.0+\rcntB,\iC=0+1}{\numexpr\the\cntB+1\relax}{%
        \ifodd\iC
          \ifnum\iC<\iB
            \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
          \fi
        \else
          \psSolid[object=plan,definition=equation, args={[0 0 1 -\r]},base=0 1 0 1]
        \fi}
    \end{pspicture}%
  }%
  \multiply\cntA by 2
  \multiply\cntB by 2
  \pstFPdiv\rcntB{1}{\the\cntB}
}
\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.