%! % Exploring random 4th order lowpass polynomials % ============================================== % Don Lancaster and Synergetics www.tinaja.com % Has anything been missed using well known polynomials? % ///////// (A) WEB FRIENDLY COLOR UTILITIES ///////////// % tintmat is a self-generating list of 216 triple color values /webtintmat [ 0 1 5 { /a exch store 0 1 5 { /b exch store 0 1 5 { 5 div b 5 div a 5 div }for } for } for ] def % setwebtint accepts a color number 0 to 215 and then % sets the PostScript color generator for later use... /setwebtint { abs cvi 216 cvi mod % restrict range webtintmat exch 3 mul 3 getinterval % get values from table aload pop setrgbcolor} def % and set them % The blocks are arranged as red to the right, green % up in order of increasing blue. % Some "pure color" sequences are % red: 0 1 2 3 4 5 % orange: 0 7 8 15 16 23 (sort of) % yellow: 0 7 14 21 28 35 % green: 0 6 12 18 24 30 % aqua: 0 42 84 126 168 210 % blue: 0 36 72 108 144 180 % magenta: 0 37 74 111 148 185 % purple 0 73 73 110 147 183 (sort of) % gray 0 43 86 129 172 215 % ////////////// GONZO EXCERPTS ////////////////// /setgrid { /blocksize exch def translate % simplified blocksize dup scale} def % repeats [ proc distance trips] xrpt /xrpt{gsave aload pop /trips exch def /dist exch def /rproc exch def trips { gsave rproc grestore dist 0 translate } repeat grestore} def /yrpt{gsave aload pop /trips exch def /dist exch def /rproc exch def trips { gsave rproc grestore 0 dist translate } repeat grestore} def % mergestr merges the two top stack strings into one top stack string /mergestr {2 copy length exch length add string dup dup 4 3 roll 4 index length exch putinterval 3 1 roll exch 0 exch putinterval} def /dot { currentpoint newpath 0.150 0 360 arc fill } def /mdot { m dot} def /random {rand 65536 div 32768 div mul cvi} def % as in -- 6 random -- 12345 srand /mt {moveto} store /showgrid {gsave /vblocks exch def /hblocks exch def thingridlines setlinewidth [{0 0 moveto 0 vblocks rlineto stroke} 1 hblocks 1 add] xrpt [{0 0 moveto hblocks 0 rlineto stroke} 1 vblocks 1 add] yrpt fatterborder { gsave newpath 0 0.96 blocksize div dtransform round idtransform setlinewidth pop 2 setlinecap 0 0 moveto hblocks 0 rlineto 0 vblocks rlineto hblocks neg 0 rlineto closepath stroke grestore} if fat5 { gsave newpath 0 0.48 blocksize div dtransform round idtransform setlinewidth pop mark {5 0 moveto 0 vblocks rlineto stroke} 5 hblocks 5 div cvi] xrpt mark {0 5 moveto hblocks 0 rlineto stroke} 5 vblocks 5 div cvi] yrpt grestore} if fatter10 { gsave newpath 0 0.96 blocksize div dtransform round idtransform setlinewidth pop mark {10 0 moveto 0 vblocks rlineto stroke} 10 hblocks 10 div cvi] xrpt mark {0 10 moveto hblocks 0 rlineto stroke} 10 vblocks 10 div cvi] yrpt grestore} if grestore} def /fatterborder {true } store /fat5 {false} store /fatter10 { false} store /thingridlines {0} store /font1 {/StoneSans-Bold findfont 1.3 scalefont setfont} store font1 0.1 setlinewidth %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% code starts here %%%% % generate values for 100 semilog frequencies from 0.1 to 10 hertz... % avoids excessive log or exp error or time pileups. mark 0.1 100 {dup 1.0471296 mul} repeat] /freqlist exch store % freqlist == % freqlist 50 get == % checks to 4 places! % build a semilog display 100 100 10 setgrid % 40 60 showgrid % log values instead 0 0 mt 0 60 rlineto 40 0 rlineto % outline and fill 0 -60 rlineto closepath gsave 214 setwebtint fill grestore 192 setwebtint 0.15 setlinewidth stroke 20 0 moveto 0 60 rlineto stroke 0.1 setlinewidth 0 57 mt 40 0 rlineto stroke % three decibels? 0 47 mt 40 0 rlineto stroke % three decibels?temp -10 0 0 mt 0 -1 rlineto stroke 20 0 mt 0 -1 rlineto stroke 40 0 mt 0 -1 rlineto stroke %%%%% draw the loglines /loglines [ 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100 ] store 0.1 setlinewidth 180 setwebtint 0 1 loglines length 1 sub % draw verticals {/ptr exch store loglines ptr get log 10 mul 2 mul 0 mt 0 60 rlineto stroke} for 20 0 mt 0 60 rlineto stroke % decibel lin lines 0 1 6 {/posn exch store -1 posn 10 mul moveto 41 0 rlineto stroke} for -1 57 mt 40 0 rlineto stroke % three decibels? 86 setwebtint font1 16.5 -5 moveto (FREQUENCY) show gsave -4 27 translate 90 rotate 0 0 moveto (DECIBELS) show grestore -3.5 0 0.45 sub moveto (-60) show -3.5 10 0.45 sub moveto (-50) show -3.5 20 0.45 sub moveto (-40) show -3.5 30 0.45 sub moveto (-30) show -3.5 40 0.45 sub moveto (-20) show -3.5 50 0.45 sub moveto (-10) show -3.2 57 0.45 sub moveto (-3) show -3.2 60 0.45 sub moveto (-0) show 0 0.8 sub -3 moveto (0.1) show 20 0.8 sub -3 moveto (1.0) show 40 1.4 sub -3 moveto (10.0) show % order 2 1 db peak lowpass /d1 1.059 store % /f1x 1.23 store /order2lopass { f1 dup mul dup mul d1 dup mul 2 sub f1 dup mul mul add 1 add sqrt log 20 mul neg} store 0 60 moveto 0 1 100 {freqlist exch get /curf exch store /f1 curf f1x mul store order2lopass /curamp exch store curf 10 mul log 20 mul curamp 60 add lineto % ( ) print curf == curamp == } for stroke (\n\n\n\n) print % check width 0 20 moveto 0 1 100 {freqlist exch get /curf exch store curf 10 mul log 20 mul % dup == 20 moveto dot } for /d1 1.414 store 5 setwebtint 0 60 moveto 0 1 100 {freqlist exch get /curf exch store /f1 curf store order2lopass /curamp exch store curf 10 mul log 20 mul curamp 60 add lineto ( ) print % curf == curamp == } for stroke %%%%% try slight dips %%%%%%%%%%%%%% % (\n\n\n\n) print 0 -10 translate 0 setwebtint 0 0 moveto 10 10 lineto stroke 0 -.007 3 add moveto dot /trim3db 1.0 store /f1x 0.709 store % slight dips values /d1 1.534 store /f2x 0.971 store /d2 0.563 store /f1x 1.000 store % butterworth value /d1 1.848 store /f2x 1.000 pop 4.00 store /d2 0.765 store /f1x 0.443 store % butterworth value /d1 0.929 store /f2x 0.950 store /d2 0.179 store % sqrt f^4 + (d^2-2)f^2 + 1 /amp1 { f1 dup mul dup mul d1 dup mul 2 sub f1 dup mul mul add 1 add sqrt log 20 mul neg} store /amp2 { f2 dup mul dup mul d2 dup mul 2 sub f2 dup mul mul add 1 add sqrt log 20 mul neg} store 0 60 moveto 0 1 100 {dup 2.5 div /posn exch store % for 40 units wide freqlist exch get trim3db mul /curf exch store /f1 curf f1x div store amp1 5 setwebtint 60 add dup /first exch store posn exch % 2 copy == == moveto dot /f2 curf f2x div store amp2 30 setwebtint 60 add dup /second exch store posn exch % 2 copy == == moveto dot gsave 202 setwebtint posn first second add 60 sub moveto dot grestore % posn first second add 60 sub lineto } for stroke showpage % EOF % sqrt f^4 + (d^2-2)f^2 + 1