%! % - procedures ------------------------------------- /pi 3.141593 def % t in radians ==> [cos(t) -sin(t)] = [y(t) y'(t)] /cosine { 4 dict begin /t exch def % change to degrees /T t 180 mul pi div def [ T cos T sin neg ] end } def % - picture ---------------------------------------- gsave % change scale to inches 72 dup scale 1 1 translate 0.01 setlinewidth % centre the coordinates 3.25 1.5 translate % for magnification?: 1 1 scale % - put in the grid ----------------------------- /top 1.5 def /bottom -1.5 def /left -3.25 def /right 3.25 def newpath 0.75 0.75 1 setrgbcolor % 0.5 setgray /x -3.2 def 65 { x bottom moveto x top lineto /x x 0.1 add def } repeat /y -1.4 def 30 { left y moveto right y lineto /y y 0.1 add def } repeat stroke % - put in some axes ---------------------------- 0 0 1 setrgbcolor newpath left 0 moveto right 0 lineto 0 bottom moveto 0 top lineto stroke % - now do the graph -------------------------- % try with 8 curves ---------------------- % choose the number of Bezier curves /N 8 def /t pi neg def % set the step size /h 2 pi mul N div def 0 0 0 setrgbcolor newpath % start the graph /x t def t cosine aload pop /slope exch def /y exch def x y moveto N { % x1 y1 x h 3 div add y h 3 div slope mul add /t t h add def /x t def t cosine aload pop /slope exch def /y exch def % x2 y2 x h 3 div sub y h 3 div slope mul sub % x3 y3 x y curveto } repeat stroke grestore showpage