[pstricks] \multido

Michael Sharpe msharpe at ucsd.edu
Mon Apr 12 19:45:35 CEST 2010


On Apr 12, 2010, at 9:58 AM, Juergen Gilg wrote:

> Dear list,
> 
> in the following example is some \multido - code to calculate some intersection points of circles.
> 
> However when increasing the number of repeating the multido-loop, i get a PS error.
> 
> The following example works -- however when increasing the loop number from 5 to 6 (or bigger), some PS errors come along.
> There are four intersection points missing in my example file -- for sure i can calculate them by hand and insert them, but i am interested in what is going wrong with my calculation  code. Must be something with negative expressions within the square root.
> 
> Here the code:
> 
> %%%%%%%%%%%%%%%%%%
> \documentclass{article}
> \usepackage{pstricks-add}
> \begin{document}
> \begin{center}
> \begin{pspicture*}(-1,-4)(4,4)
> \multido{\rA=1+0.5}{8}{
> \psarc[linewidth=0.5pt,linecolor=lightgray](0,1){\rA}{-90}{90}
> \psarc[linewidth=0.5pt,linecolor=lightgray](0,-1){\rA}{-90}{90}
> }
> \multido{\rA=1+0.5}{5}{
> \multido{\rB=1+0.5}{5}{
> %\pscircle*(!\rA\space 2 exp 1 sub sqrt 0){0.05}
> \pscircle*(!\rA\space 2 exp \rB\space 2 exp sub 4 add 4 div \rA\space div 2 exp neg 1 add sqrt \rA\space mul  \rA\space 2 exp \rB\space 2 exp sub 4 add 4 div 1 sub){0.05}
> }}
> \psframe[fillstyle=solid,fillcolor=white,linecolor=white](-0.2,6)(0.5,-6)
> \pspolygon[fillstyle=solid,fillcolor=white,linecolor=white](3,6)(3,-6)(6,-6)(6,6)(3,6)
> \pspolygon[fillstyle=solid,fillcolor=white,linecolor=white](0,0)(0,-6)(3,-6)(3,-3)(0,0)
> \pspolygon[fillstyle=solid,fillcolor=white,linecolor=white](0,0)(0,6)(3,6)(3,3)(0,0)
> \psdot(0,1)
> \psdot(0,-1)
> \psline[linewidth=2pt](3,-3)(3,3)
> %\psgrid
> \end{pspicture*}
> \end{center}
> \end{document}
> %%%%%%%%%%%%%%%%%%%%%
> 
> Any explanations and help appreciated.
> Anyone an idea?
> 
> Thanks in advance.
> 
> Regards,
> 
> Juergen

You are taking the square root of 1-(\frac{x^2-y^2-4}{4x})^2, which can be negative if y>x-2. That does not happen until you reach 6 or more iterations.

Michael




More information about the PSTricks mailing list