Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!imagen!daemon From: ib@apolling (Ivan N. Bach) Newsgroups: comp.lang.postscript Subject: Parametric Function Message-ID: <3069@imagen.UUCP> Date: 21 Feb 89 00:57:25 GMT Sender: daemon@imagen.UUCP Lines: 56 Here is a PostScript program that draws a very nice parametric function in landscape orientation. This function was described in the section "Computer Recreations" of the August 1988 issue of "Scientific American." It would be faster to calculate all values of the x(t) and y(t) functions in a different programming language, such as C, and then generate PostScript code to connect the points at calculated coordinates, but I wanted to write the whole program in PostScript. ------------------------------ cut here ---------------------------------- %! % A parametric function based on an article printed in the August 1988 % issue of "Scientific American": % % x(t) = 800(sin(.99t)-.7cos(3.01t))+1653 (at 300 dpi) % y(t) = 800(cos(1.01t)+.1sin(15.03t))+1275 (at 300 dpi) % t = 0, 1, 2, ..., 50000 % % The parameter t reaches the value of only 49435 in this program. % specify the number of copies userdict begin /#copies 1 def end % define the x(t) function /x { .99 t mul sin 3.01 t mul cos .7 mul sub 800 mul 1653 add 300 div 72 mul } bind def % define the y(t) function /y { 1.01 t mul cos 15.03 t mul sin .1 mul add 800 mul 1275 add 300 div 72 mul } bind def % use the thinnest line 0 setlinewidth % use the landscape orientation -90 rotate -11 72 mul 0 translate /t 0 def x y moveto 33 { % do not exceed the maximum number of path segments (1500) 1499 { x y lineto t 1 add /t exch def } repeat stroke t 1 sub /t exch def x y moveto } repeat showpage