%!PS-Adobe- % spiral45.ps % Steve Witham % 2003.01.12 % derived from polar_grid.ps /inch { 72 mul } def /swap { exch } def % This works best if set to the printer resolution % (which is settable in my printer). /resolution 1 1200 div inch def /minwidth resolution 6 mul def /fadeweight minwidth 1 div def /sqrtfade minwidth fadeweight div sqrt def false setstrokeadjust /setlineweight { % "thickness" -- dup fadeweight gt { % Above this weight thicken like sqrt: minwidth div sqrt minwidth mul } { % else Below it, fade like x^2: fadeweight div dup mul fadeweight mul } ifelse dup dup minwidth lt { pop minwidth } { % else resolution div ceiling resolution mul } ifelse dup setlinewidth div 1 exch sub setgray } def /circle { % x y r -- 0 360 arc stroke } def /center { % -- x y 0 0 } def /tan { dup sin exch cos div } def /pi 3.1415926 def /e 2.7182818 def /deg_to_rad { 180 div pi mul } def /calc_angle_f { /angle 360 nsegs div def % We're making a polar coordinate grid. % The circles have exponentially decreasing radii: % 1, f, f^2, etc. % The angle between the spokes is "angle", fixed above. % We want the grid "squares" to be approximately square, % so we're going to calculate f to do that. % % It turns out f = e ^ -angle_in_radians. /fraction e angle deg_to_rad neg exp def /sf fraction sqrt def } def /drawspiral { % x y radius nsegs -- /nsegs exch def /outr exch def calc_angle_f gsave translate /weight outr 6 div nsegs div def /s angle 2 div sin def /c angle 2 div cos def /s45 angle 2 div 45 add sin def /c45 angle 2 div 45 add cos def { weight setlineweight /sw weight sf mul def /sr outr sf mul def /inr outr fraction mul def /ssr s sr mul def /csr c sr mul def /cf .634 def % For each of the curves drawn, there are two % non-endpoint control points. cf is the fraction % of the distance each control points is along a % tangent towards the intersection of the tangents. % I tried cf = 1 (too pointy), 1/2 (too flat), % 2/3 (pretty good till nsegs = 4), .634 (oof). /j csr ssr sub inr sub c45 s45 sub div def /dy ssr s45 j mul sub def /k outr csr sub ssr sub s45 c45 sub div def % BAD TO USE A GLOBAL CALLED "e" ! /ey ssr c45 k mul sub def gsave nsegs { weight setlineweight % newpath csr ssr moveto outr 0 lineto % csr ssr neg lineto % stroke newpath csr ssr moveto csr s45 k mul cf mul add ssr c45 k mul cf mul sub outr ey cf mul sub ey cf mul outr 0 curveto outr ey cf mul sub ey cf mul neg csr s45 k mul cf mul add ssr c45 k mul cf mul sub neg csr ssr neg curveto stroke sw setlineweight % newpath csr ssr moveto inr 0 lineto % csr ssr neg lineto % stroke newpath csr ssr moveto csr c45 j mul cf mul sub ssr s45 j mul cf mul sub inr dy cf mul add dy cf mul inr 0 curveto inr dy cf mul add dy cf mul neg csr c45 j mul cf mul sub ssr s45 j mul cf mul sub neg csr ssr neg curveto stroke angle rotate } repeat grestore /weight weight fraction mul def weight minwidth 8 div lt { exit } if inr 1 300 div inch lt { exit } if /outr inr def } loop % dot in the center 0 setgray 0 0 minwidth 0 360 arc fill grestore } def % 8.5 inch 2 div 11 inch 2 div 4 inch 8 drawspiral % showpage 8.5 inch 2 div 11 inch 2 div 7 inch 256 drawspiral 8.5 inch 2 div 11 inch 2 div 7 inch 128 drawspiral 8.5 inch 2 div 11 inch 2 div 7 inch 64 drawspiral 8.5 inch 2 div 11 inch 2 div 7 inch 32 drawspiral 8.5 inch 2 div 11 inch 2 div 7 inch 16 drawspiral 8.5 inch 2 div 11 inch 2 div 7 inch 8 drawspiral 8.5 inch 2 div 11 inch 2 div 7 inch 4 drawspiral showpage 1.5 inch 1.5 inch 14 inch 512 drawspiral 1.5 inch 1.5 inch 14 inch 256 drawspiral 1.5 inch 1.5 inch 14 inch 128 drawspiral 1.5 inch 1.5 inch 14 inch 64 drawspiral 1.5 inch 1.5 inch 14 inch 32 drawspiral 1.5 inch 1.5 inch 14 inch 16 drawspiral 1.5 inch 1.5 inch 14 inch 8 drawspiral 1.5 inch 1.5 inch 14 inch 4 drawspiral showpage