[pstricks] FW: [PostScript] repeat-loop
Herbert Voss
Herbert.Voss at alumni.TU-Berlin.DE
Tue Oct 12 11:58:19 CEST 2004
Goebel, Juergen, OPE26 wrote:
> 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).
ok, understood
Herbert
\documentclass{scrartcl}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{pst-key}
\makeatletter
\define at key{psset}{nLoop}{\def\psnLoop{#1}}
\psset{nLoop=1}
\makeatother
\begin{document}
\psset{unit=1mm}
\begin{pspicture}(-45,0)(45,30)
\psaxes[Dy=10,Dx=15]{->}(0,0)(-45,0)(45,30)
\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
/Func {
/nLoop exch def
x kx mul nLoop mul cos
nLoop dc mul si mul
} def
}
\psplot[plotpoints=200,linecolor=red,plotstyle=curve,nLoop=5]{-45}{45}{%
/y0 x kx mul cos dc si mul def
/y1 0 def
1 1 \psnLoop {
Func y1 add /y1 exch def
} for
y1 y0 add
dc mul 2 mul
dc add
ky mul
}
\end{pspicture}
\end{document}
--
http://TeXnik.de/
http://PSTricks.de/
ftp://ftp.dante.de/tex-archive/info/math/voss/Voss-Mathmode.pdf
http://www.dante.de/faq/de-tex-faq/
http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes
More information about the PSTricks
mailing list