[pstricks] FW: [PostScript] repeat-loop

Goebel, Juergen, OPE26 juergen.goebel at eads.com
Tue Oct 12 10:29:48 CEST 2004


This should go to the list, not per PM - sorry again.
(I think I should check the to-address more thoroughly.)

Hi Herbert,
 
> Herbert Voss [mailto:Herbert.Voss at alumni.TU-Berlin.DE] schrieb:
 
[solution with explanation - I hope I get it right]
 
> However, I can not get any useful graphic.
 
That's right, neither can I. ;-)
Have a look at the following lines.
 
 
\documentclass{scrartcl}
\usepackage{pstricks}
\usepackage{pst-plot}
\begin{document}
  \psset{unit=1mm}
  \begin{pspicture}(90,30)
  \rput(45,0){%
      \pstVerb{%
         /dc 0.2 def
         /kx 12 def
         /ky 12 def
         /pi 3.141529 def
         /rad2deg { 57.296 mul } def
         /si { pi mul dup rad2deg sin exch div } def
      }
      \psplot[linecolor=red,plotstyle=curve]{-45}{45}{%
         x kx mul cos
         dc si
         mul
         /n 2 def
         x kx mul n mul cos       % these lines
         n dc mul si              % these lines
         mul                      % these lines
         add
         dc mul 2 mul
         dc add
         ky mul
      }
  }
  \end{pspicture}
\end{document}


The three marked lines have to be summed up for increasing n.
Of course I can copy'n'paste it several times, but this is
neither elegant nor efficient. So I tried to pack it into a
loop. Probably the for-loop is simpler, but my problem all
the way is the handling of the loop-index (as you can see).

> Look at the code is it okay in this way?

Hm, not exactly, but at this moment I cannot identify where 
the problem is. Maybe you can help me again ...

Thanks,

Jürgen
 




More information about the PSTricks mailing list