%! % - 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 1 0.75 0.75 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 ---------------------------- 1 0 0 setrgbcolor newpath left 0 moveto right 0 lineto 0 bottom moveto 0 top lineto stroke % - now do the graph -------------------------- % try once with 2 curves ---------------------- % choose the number of Bezier curves /N 2 def /t pi neg def % set the step size /h 2 pi mul N div def 0 1 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 % choose again the number of Bezier curves /N 4 def /t pi neg def % set the step size /h 2 pi mul N div def 0 0 1 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 % try again with 4 curves ---------------------- 0 setgray % choose the number of Bezier curves /N 8 def /t pi neg def % set the step size /h 2 pi mul N div def 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 % draw the box and clip to it newpath -3.25 -1.5 moveto 6.5 0 rlineto 0 3 rlineto -6.5 0 rlineto closepath stroke grestore showpage gsave % change scale to inches 72 dup scale 1 1 translate 0.01 setlinewidth % centre the coordinates 3.25 1.5 translate % for magnification: 4 4 scale % - put in the grid ----------------------------- /top 1.5 def /bottom -1.5 def /left -3.25 def /right 3.25 def newpath 1 0.75 0.75 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 ---------------------------- 1 0 0 setrgbcolor newpath left 0 moveto right 0 lineto 0 bottom moveto 0 top lineto stroke % - now do the graph -------------------------- % try once with 2 curves ---------------------- % choose the number of Bezier curves /N 2 def /t pi neg def % set the step size /h 2 pi mul N div def 0 1 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 % choose again the number of Bezier curves /N 4 def /t pi neg def % set the step size /h 2 pi mul N div def 0 0 1 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 % try again with 4 curves ---------------------- 0 setgray % choose the number of Bezier curves /N 8 def /t pi neg def % set the step size /h 2 pi mul N div def 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 % draw the box and clip to it newpath -3.25 -1.5 moveto 6.5 0 rlineto 0 3 rlineto -6.5 0 rlineto closepath stroke grestore showpage