2

Consider the following example:

Code

% xelatex filename.tex

\documentclass{article}

\usepackage{pst-poly,pstricks-add}
\usepackage[locale=DE]{siunitx}

\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

\begin{document}

\def\radius{5 }
\def\factorA{\calc{(1/10*(5+5^(1/2)))^(1/2)*\radius}}
\def\factorB{\calc{1/2*(3+5^(1/2))}}
\def\factorC{\calc{\factorA*\factorB}}
%\def\firstcoor{\calc{5/4*(5^(1/2)-1)*\factorB}}
%\def\secondcoor{\calc{1/4*(10*(5+5^(1/2)))^(1/2)*\factorB}}
\def\dist{\calc{(1/10*(5-5^(1/2)))^(1/2)*\factorB*\radius}}
\def\firstcoorA{\calc{\dist*cos(3/10*pi)}}
\def\secondcoorA{\calc{\dist*sin(3/10*pi)}}
\def\firstcoorB{\calc{\dist*cos(7/10*pi)}}
\def\secondcoorB{\calc{\dist*sin(7/10*pi)}}
\def\firstcoorC{\calc{\dist*cos(11/10*pi)}}
\def\secondcoorC{\calc{\dist*sin(11/10*pi)}}
\def\firstcoorD{\calc{\dist*cos(15/10*pi)}}
\def\secondcoorD{\calc{\dist*sin(15/10*pi)}}
\def\firstcoorE{\calc{\dist*cos(19/10*pi)}}
\def\secondcoorE{\calc{\dist*sin(19/10*pi)}}

\psset{unit=0.5}
\begin{pspicture}(-10.7,-11.2)(10.7,9)
{\psset{%
  linewidth=2\pslinewidth,%
  linecolor=green!90!yellow!70!blue!70,%
  fillstyle=solid,%
  fillcolor=green!60!yellow!80!blue!80%
 }
 \rput(0,0){\PstPentagon[unit=\factorA]}
 \rput{ 36}(\firstcoorA,\secondcoorA){\PstPentagon[unit=\factorA]}
 \rput{ 36}(\firstcoorB,\secondcoorB){\PstPentagon[unit=\factorA]}
 \rput{ 36}(\firstcoorC,\secondcoorC){\PstPentagon[unit=\factorA]}
 \rput{180}(\firstcoorD,\secondcoorD){\PstPentagon[unit=\factorA]}
 \rput{ 36}(\firstcoorE,\secondcoorE){\PstPentagon[unit=\factorA]}
}
 \rput{180}(0,0){\PstPentagon[unit=\factorC,linewidth=2\pslinewidth]}
 \rput(!0.8 \radius mul neg 0.26 \radius mul neg){\num{\radius}}
\end{pspicture}

\end{document}

Output

output

Question

How do I use the \multido command to draw the five green pentagons around the center one?

3
\documentclass{article}
\usepackage{pst-poly}  
\begin{document}
\def\Radius{2 } \def\myCoor{}

\begin{pspicture}[showgrid](-5,-5)(5,5)
\psset{linewidth=2\pslinewidth,%
  linecolor=green!90!yellow!70!blue!70,%
  fillstyle=solid,fillcolor=green!60!yellow!80!blue!80}
 \rput(0,0){\PstPentagon[unit=\Radius]}
 \pstVerb{/R1 \Radius 36 cos mul dup add def /R2 R1 \Radius add def }
 \multido{\iA=-90+72}{5}{%
   \xdef\myCoor{\myCoor(!R2 \iA\space PtoC)} %
   \rput{36}(! R1 \iA\space PtoC){\PstPentagon[unit=\Radius]}}
 \psset{linecolor=black,linewidth=1.5pt,fillstyle=none}
 \expandafter\pspolygon\myCoor
\end{pspicture}

\end{document}

enter image description here

  • Great, Herbert! (Btw. what have you edited? I copied the code before the edit.) – Svend Tveskæg Jun 19 '13 at 10:17
  • deleted an empty line :-) – user2478 Jun 19 '13 at 10:25
  • Have you made another change to the code? (I haven't been on TeX Stack Exchange for a couple of days and now the code looks different from what I have, I think.) If so, would you give a short explanation of what it is good for? – Svend Tveskæg Jun 22 '13 at 17:41
  • click on the "edite 2 dyas ago" and you'll see the changes – user2478 Jun 22 '13 at 19:59
  • Thank you. Can you tell me what this new code does compared to the old one? – Svend Tveskæg Jun 22 '13 at 20:43

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.