%!PS % Fulfor Full Fourier Analyzer DOUBLE CYCLE % ============================= % by Don Lancaster % ========= % attempts to verify third party sine and cosine components over one full cycle % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is required for this program. % After obvious location mods, uncomment ONE of the following two lines: % (C:\\Documents and Settings\\Bee\\Desktop\\Gonzo\\gonzo.ps) run % use internal gonzo (C:\\gonzo2\\gonzo.ps)run % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % GONZO20A Guru Gonzo PostScript power tools (Interim release) % Includes gonzo justification and layout utilities. % Copyright c 1990, 1996, 2001 by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. /ps.util.1 {gutil} def % substitute old name /gutility {gutil} def % substitute old name /guru { gonzo begin ps.util.1 begin printerror nuisance begin} def % jumpstart 200 dict /gutil exch def gutil begin % eof % define four quadrant data as arrays of [startang1 endang1 ampolarity1 startang2 endang2 ampolarity2 ...] /square090 [ 0 90 1] store % square wave for debug /square90180 [ 90 180 1 ] store /square180270 [180 270 -1] store /square270360 [270 360 -1 ] store %%%% BEFF 8 here /ang53 [ % angle-position pairs data best efficiency 8 0.53 may be lower amplitude than third party 10.5469382348 % p1s 11.6800357208 % p1e 21.1285109543 % p2s 23.3598053345 % p2e 31.7786679175 % p3s 35.0379144382 % p3e 42.5295661452 % p4s 46.7102405693 % p4e 53.4095480813 % p5s 58.3675249346 % p5e 64.4397435676 % p6s 69.9924227481 % p6e 75.6293832304 % p7s 81.5576901123 % p7e 86.9714692342 % p8s 90 % p8e ] store /ang53orig [ % from old series II calculator 5.627729372532276 6.19843404746768 15.954913056116387 17.64272648388345 26.514295209330125 29.26888822066971 37.18699684487815 40.920239035121796 47.98464610634204 52.57145154365792 58.92717334595 64.20427732405014 70.02825035122738 75.7943652487726 81.2883086080619 87.3089976319381 ] store /q1beff853090 mark ang53 0 get ang53 1 get 1 ang53 2 get ang53 3 get 1 ang53 4 get ang53 5 get 1 ang53 6 get ang53 7 get 1 ang53 8 get ang53 9 get 1 ang53 10 get ang53 11 get 1 ang53 12 get ang53 13 get 1 ang53 14 get ang53 15 get 1 ] store /q2beff853090 mark 180 ang53 0 get sub 180 ang53 1 get sub exch 1 180 ang53 2 get sub 180 ang53 3 get sub exch 1 180 ang53 4 get sub 180 ang53 5 get sub exch 1 180 ang53 6 get sub 180 ang53 7 get sub exch 1 180 ang53 8 get sub 180 ang53 9 get sub exch 1 180 ang53 10 get sub 180 ang53 11 get sub exch 1 180 ang53 12 get sub 180 ang53 13 get sub exch 1 180 ang53 14 get sub 180 ang53 15 get sub exch 1 ] store /q3beff853090 mark 180 ang53 0 get add 180 ang53 1 get add -1 180 ang53 2 get add 180 ang53 3 get add -1 180 ang53 4 get add 180 ang53 5 get add -1 180 ang53 6 get add 180 ang53 7 get add -1 180 ang53 8 get add 180 ang53 9 get add -1 180 ang53 10 get add 180 ang53 11 get add -1 180 ang53 12 get add 180 ang53 13 get add -1 180 ang53 14 get add 180 ang53 15 get add -1 ] store /q4beff853090 mark 360 ang53 0 get sub 360 ang53 1 get sub exch -1 360 ang53 2 get sub 360 ang53 3 get sub exch -1 360 ang53 4 get sub 360 ang53 5 get sub exch -1 360 ang53 6 get sub 360 ang53 7 get sub exch -1 360 ang53 8 get sub 360 ang53 9 get sub exch -1 360 ang53 10 get sub 360 ang53 11 get sub exch -1 360 ang53 12 get sub 360 ang53 13 get sub exch -1 360 ang53 14 get sub 360 ang53 15 get sub exch -1 ] store %%%% REG 8 here /q1reg853090 mark ang53orig 0 get ang53orig 1 get 1 ang53orig 2 get ang53orig 3 get 1 ang53orig 4 get ang53orig 5 get 1 ang53orig 6 get ang53orig 7 get 1 ang53orig 8 get ang53orig 9 get 1 ang53orig 10 get ang53orig 11 get 1 ang53orig 12 get ang53orig 13 get 1 ang53orig 14 get ang53orig 15 get 1 ] store /q2reg853090 mark 180 ang53orig 0 get sub 180 ang53orig 1 get sub exch 1 180 ang53orig 2 get sub 180 ang53orig 3 get sub exch 1 180 ang53orig 4 get sub 180 ang53orig 5 get sub exch 1 180 ang53orig 6 get sub 180 ang53orig 7 get sub exch 1 180 ang53orig 8 get sub 180 ang53orig 9 get sub exch 1 180 ang53orig 10 get sub 180 ang53orig 11 get sub exch 1 180 ang53orig 12 get sub 180 ang53orig 13 get sub exch 1 180 ang53orig 14 get sub 180 ang53orig 15 get sub exch 1 ] store /q3reg853090 mark 180 ang53orig 0 get add 180 ang53orig 1 get add -1 180 ang53orig 2 get add 180 ang53orig 3 get add -1 180 ang53orig 4 get add 180 ang53orig 5 get add -1 180 ang53orig 6 get add 180 ang53orig 7 get add -1 180 ang53orig 8 get add 180 ang53orig 9 get add -1 180 ang53orig 10 get add 180 ang53orig 11 get add -1 180 ang53orig 12 get add 180 ang53orig 13 get add -1 180 ang53orig 14 get add 180 ang53orig 15 get add -1 ] store /q4reg853090 mark 360 ang53orig 0 get sub 360 ang53orig 1 get sub exch -1 360 ang53orig 2 get sub 360 ang53orig 3 get sub exch -1 360 ang53orig 4 get sub 360 ang53orig 5 get sub exch -1 360 ang53orig 6 get sub 360 ang53orig 7 get sub exch -1 360 ang53orig 8 get sub 360 ang53orig 9 get sub exch -1 360 ang53orig 10 get sub 360 ang53orig 11 get sub exch -1 360 ang53orig 12 get sub 360 ang53orig 13 get sub exch -1 360 ang53orig 14 get sub 360 ang53orig 15 get sub exch -1 ] store /adj {curharm div pi div} store /pi 3.1415926 store /analyzefuoriersineerms { mark % start output array 1 1 maxharms {/curharm exch store 0 % start accumulation 0 3 quad1 length 1 sub { /curpulse exch store quad1 curpulse get 2 div curharm mul cos quad1 curpulse 1 add get 2 div curharm mul cos sub quad1 curpulse 2 add get mul add } for % for each pulse % dup adj == 0 3 quad2 length 1 sub { /curpulse exch store quad2 curpulse get 2 div curharm mul cos quad2 curpulse 1 add get 2 div curharm mul cos sub quad2 curpulse 2 add get mul add } for % for each pulse % dup adj == 0 3 quad3 length 1 sub { /curpulse exch store quad3 curpulse get 2 div curharm mul cos quad3 curpulse 1 add get 2 div curharm mul cos sub quad3 curpulse 2 add get mul add } for % for each pulse % dup adj == 0 3 quad4 length 1 sub { /curpulse exch store quad4 curpulse get 2 div curharm mul cos quad4 curpulse 1 add get 2 div curharm mul cos sub quad4 curpulse 2 add get mul add } for % for eachpulse % dup adj == 0 3 quad5 length 1 sub { /curpulse exch store quad5 curpulse get 2 div curharm mul cos quad5 curpulse 1 add get 2 div curharm mul cos sub quad5 curpulse 2 add get mul add } for % for each pulse % dup adj == 0 3 quad6 length 1 sub { /curpulse exch store quad6 curpulse get 2 div curharm mul cos quad6 curpulse 1 add get 2 div curharm mul cos sub quad6 curpulse 2 add get mul add } for % for each pulse % dup adj == 0 3 quad3 length 1 sub { /curpulse exch store quad7 curpulse get 2 div curharm mul cos quad7 curpulse 1 add get 2 div curharm mul cos sub quad7 curpulse 2 add get mul add } for % for each pulse % dup adj == 0 3 quad4 length 1 sub { /curpulse exch store quad8 curpulse get 2 div curharm mul cos quad8 curpulse 1 add get 2 div curharm mul cos sub quad8 curpulse 2 add get mul add } for % for eachpulse % dup adj == curharm div % scale final value pi div % scale by pi scaleharms div % normalize to fundamental MUST CHANGE EACH TIME % (\n\n\n) print flush } for % for each harmonic ] /cterms exch store } store /analyzefouriercosterms { mark % start output array 1 1 maxharms {/curharm exch store 0 % start accumulation 0 3 quad1 length 1 sub { /curpulse exch store quad1 curpulse get curharm mul sin quad1 curpulse 1 add get curharm mul sin sub quad1 curpulse 2 add get mul add } for % for each pulse 0 3 quad2 length 1 sub { /curpulse exch store quad2 curpulse get curharm mul sin quad2 curpulse 1 add get curharm mul sin sub quad2 curpulse 2 add get mul add } for % for each pulse 0 3 quad3 length 1 sub { /curpulse exch store quad3 curpulse get curharm mul sin quad3 curpulse 1 add get curharm mul sin sub quad3 curpulse 2 add get mul add } for % for each pulse 0 3 quad4 length 1 sub { /curpulse exch store quad4 curpulse get curharm mul sin quad4 curpulse 1 add get curharm mul sin sub quad4 curpulse 2 add get mul add } for % for each pulse 0 3 quad5 length 1 sub { /curpulse exch store quad5 curpulse get curharm mul sin quad5 curpulse 1 add get curharm mul sin sub quad5 curpulse 2 add get mul add } for % for each pulse 0 3 quad6 length 1 sub { /curpulse exch store quad6 curpulse get curharm mul sin quad6 curpulse 1 add get curharm mul sin sub quad6 curpulse 2 add get mul add } for % for each pulse 0 3 quad7 length 1 sub { /curpulse exch store quad7 curpulse get curharm mul sin quad7 curpulse 1 add get curharm mul sin sub quad7 curpulse 2 add get mul add } for % for each pulse 0 3 quad8 length 1 sub { /curpulse exch store quad8 curpulse get curharm mul sin quad8 curpulse 1 add get curharm mul sin sub quad8 curpulse 2 add get mul add } for % for each pulse curharm div % scale final value pi div % scale by pi scaleharms div % normalize to fundamental MUST CHANGE EACH TIME } for % for each harmonic ] /sterms exch store } store /trunc { /xx exch store xx abs 0.001 lt {0.00}{xx} ifelse } store %%%%%%%%%%%%%%%%%% /graphit { 50 50 10 setgrid 50 40 showgrid 1 0 0 setrgbcolor 0 2 cterms length 1 sub {/curharm exch store curharm 4 div 10 mt cterms curharm 1 add get 10 mul dup dup == pu 0.5 pr pd closepath fill } for black 0 10 mt line1 50 r showpage } store %%%%%%%%%%% demo - remove or alter before reuse % set harms /maxharms 240 store % max number of reportable odd and even harmonics % select quadrants { /quad1 {square090} store /quad2 {square90180} store /quad3 {square180270} store /quad4 {square270360} store }pop /quad1 {q1beff853090} store /quad2 {q2beff853090} store /quad3 {q3beff853090} store /quad4 {q4beff853090} store /quad1 {q1reg853090} store /quad2 {q2reg853090} store /quad3 {q3reg853090} store /quad4 {q4reg853090} store /quad1 {q1beff853090} store /quad2 {q2beff853090} store /quad3 {q3reg853090} store /quad4 {q4reg853090} store /quad1 {q1beff853090} store /quad2 {q2reg853090} store /quad3 {q3reg853090} store /quad4 {q4beff853090} store /quad1 {q1beff853090} store /quad2 {q2beff853090} store /quad3 {q3beff853090} store /quad4 {q4beff853090} store /quad5 {q1reg853090} store /quad6 {q2reg853090} store /quad7 {q3reg853090} store /quad8 {q4reg853090} store /scaleharms 0.53 store stopwatchon analyzefuoriersineerms analyzefouriercosterms stopwatchoff % extra accuracy reporter can optionally go here (\n\n\n[\n) print flush sterms {trunc ==} forall (]\n\n\n[\n) print flush cterms {trunc ==} forall (\n]\n\n) print flush graphit % EOF