[pstricks] [PostScript] repeat-loop
Herbert Voss
Herbert.Voss at alumni.TU-Berlin.DE
Tue Oct 12 09:53:58 CEST 2004
Goebel, Juergen, OPE26 wrote:
> Hi,
>
> it's me again with a new question regarding PS-programming.
> I'm trying to create a simple repeat-loop using the following
> code-fragment:
>
>
> \documentclass{scrartcl}
> \usepackage{pstricks}
> \usepackage{pst-plot}
> \begin{document}
> \psset{unit=1mm}
> \begin{pspicture}(90,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
> }
> \psplot{-45}{45}{%
> /n 0 def
> 5
> { n 1 add % <-----------------------
n
/n n 1 add def
or the other way round if it should stay with the
old value on the stack
using the for loop is a bit easier:
start step end { procedure } for
puts the loop on top of the stack. But there is another Problem
when you do not use psplot in the usual way. PSTricks puts the
x coordinate in PostScript unit on top of the stack and then
calls the defined function. This is okay, when we define as
usual a function, but in this case you should first save this
value and put it at the end on the stack again.
However, I can not get any useful graphic. Look at the code
is it okay in this way?
Herbert
\documentclass{scrartcl}
\usepackage{pstricks}
\usepackage{pst-plot}
\begin{document}
\psset{unit=1mm}
\begin{pspicture}(90,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
}
\psplot{-45}{45}{%
/xPS exch def % save the PS value of x
1 1 5 {
/n exch def
x kx mul n mul cos % cos(12 n x) (1)
n dc mul si % sin(0.2n pi)/(0.2n pi) (2)
mul % (1) * (2)
n add % (1)(2)+n ???
} for
dc mul 2 mul
dc add
ky mul
xPS exch
}
\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