!! File: Fourier !! December 16, 2002 Hubert Hohn PUBLIC PCflag,Mac5flag,M68Kflag,Unixflag,xmax,ymax PUBLIC toolLft,toolRgt,toolBas,toolTop,toolhdr,toolHgt,toolWid ! tool boundaries PUBLIC winLft,winRgt,winBas,winTop,winHgt,winWid ! window PUBLIC workLft,workRgt,workBas,workTop,workMidx ! work area PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white PUBLIC red,yellow,green,cyan,blue,magenta,pink,colorscheme PUBLIC planeclr,gridclr,rimclr,axisclr,axislabelclr,titleclr,rightsclr PUBLIC numberlineclr,slotdrkclr,slotlgtclr,slideclr PUBLIC largefonts, title$, SLUmode DECLARE DEF quitWithin,infoWithin LET toolHgt= 560 LET toolWid= 780 LET window$= "d'Arbeloff Interactive Math Project" LET colorscheme= 0 LET title$ = "Fourier Series Coefficients" SUB ThisProgram CALL FourierCoefficients CLEAR END SUB !! ---------------------------------------------------------- !! ------ Start TB4 Mac Header and Subs ------ !LET M68KFlag = 1 !LIBRARY "MacTools*", "HHLib.trc" !ASK PIXELS winWid,winHgt !LET winLft= 0 !LET winTop= 0 !LET winRgt= winWid-1 !LET winBas= winHgt-1 !SET WINDOW 0,winRgt,winBas,0 !CALL Palette !CLEAR ! !CALL ToolPanel !CALL ThisProgram ! !END !EXTERNAL ! !MODULE Mac4Parts ! SUB SetTextFont(font,size,style$) ! CALL MacTextFont(font) ! CALL MacTextSize(size) ! CALL MacTextFace(style$) ! END SUB ! ! SUB StringWidth(sw$,sl) ! DECLARE DEF MacStringWidth ! LET sl= MacStringWidth(sw$) ! END SUB ! ! SUB SetLineWeight(wgt) ! CALL MacPenSize(wgt,wgt) ! END SUB ! ! SUB BoxDisk(Lft,Rgt,Bas,Top) ! CALL MacPaintOval(Lft,Rgt,Bas,Top) ! END SUB !END MODULE !! --- End TB4 Mac Header and Subs --- !!--- Start TB5 Cross-Platform header and subs --- LIBRARY "c:\TB Gold 51a\TBLibs\TrueCtrl.trc" ! windows LIBRARY "c:\TB Gold 51a\TBLibs\HHLib.trc" !LIBRARY ":TBLibs:TrueCtrl.trc" ! macintosh !LIBRARY "HHLib.trc" PUBLIC WinID DECLARE PUBLIC OBJM_SET,OBJM_SYSINFO LET winHgt= toolHgt LET winWid= toolWid DIM values(1) CALL TC_Init CALL Object(OBJM_SYSINFO,WinID,"MACHINE",system$,values()) IF system$="MAC" then LET Mac5Flag= 1 ELSE IF system$="WIN32" then LET PCFlag = 1 END IF CALL TC_SetUnitsToPixels ! 5.1 and up needs this CALL TC_GetScreenSize(scrnLft,scrnRgt,scrnBas,scrnTop) LET winLft= int((scrnRgt-scrnLft-winWid)/2) LET winRgt= winLft+winWid-1 LET winTop= int((scrnBas-scrnTop-winHgt)/2) + 10 LET winBas= winTop+winHgt-1 CALL TC_Win_Create (WinID,"TITLE",winLft,winRgt,winBas,winTop) LET values(1)= 2 CALL Object(OBJM_SET, WinID, "TYPE", "", values()) IF PCFlag=1 then ! kill dithering LET values(1)= 1 CALL Object(OBJM_SET, WinID, "SOLID MIX", "", values()) END IF LET values(1)= 0 CALL TC_SetRect(WinID,winLft,winRgt,winBas,winTop) CALL TC_Win_SetTitle(WinID,window$) CALL TC_Show(WinID) SET MODE "COLORSTANDARD" ASK PIXELS winWid,winHgt ! must follow set mode LET winLft= 0 LET winTop= 0 LET winRgt= winWid-1 LET winBas= winHgt-1 SET WINDOW 0,winRgt,winBas,0 CALL Palette IF PCFlag=1 then LET values(1)= 0 ! now force solid colors CALL Object(OBJM_SET, WinID, "SOLID MIX", "", values()) CALL TC_Win_RealizePalette(WinID) ! some PCs need this CALL TC_Win_SetFont(WinID,"arial",9,"plain") CALL StringWidth("0",sw) IF sw>7 then LET largefonts=1 else LET largefonts=0 END IF CALL TC_Win_Switch(WinID) CALL ToolPanel CALL ThisProgram CALL SetTextFont(1,12,"bold") ! now shut down and clean up LET quit$= "click the mouse or press a key to close..." CALL PlotTextCJ(workmidx,(workbas+worktop)/2,quit$,yellow) CALL TC_CleanUp END EXTERNAL MODULE TB5Parts SUB StringWidth(sw$,sl) DECLARE PUBLIC WinID LET sl= StrWidth(WinID,sw$) END SUB SUB SetLineWeight(wgt) DECLARE PUBLIC OBJM_SET DECLARE PUBLIC WinID DIM values(1) LET values(1)= wgt CALL Object(OBJM_SET,WinID, "WIDTH", "", values()) END SUB SUB SetTextFont(font,size,style$) DECLARE PUBLIC WinID,Mac5Flag,PCFlag,largefonts IF Mac5Flag=1 then SELECT CASE font CASE 4 LET font$= "Courier" CASE 16 LET font$= "Times" CASE else LET font$= "Geneva" END SELECT ELSE IF PCFlag=1 then IF largefonts=1 then IF size<12 then LET size= 6 ELSE IF size=14 then LET size= 10 ELSE IF size=18 then LET size= 12 ELSE IF size=24 then LET size= 14 ELSE IF size=12 then LET size= 8 ELSE LET size= round(72/96 * size * .8) END IF ELSE IF size<12 then LET size= 7 ELSE IF size=14 then LET size= 12 ELSE IF size=12 then LET size= 9 ELSE IF size=18 then LET size= 14 ELSE IF size=24 then LET size= 18 ELSE LET size= round(72/96 * size) END IF END IF SELECT CASE font CASE 4 LET font$= "Courier New" CASE 16 LET font$= "Times New Roman" CASE else LET font$= "Verdana" END SELECT END IF IF style$= "normal" then LET style$= "plain" CALL TC_Win_SetFont(WinID,font$,size,style$) END SUB SUB BoxDisk(Lft,Rgt,Bas,Top) BOX DISK Lft,Rgt,Bas,Top END SUB END MODULE ! --- End TB5 Cross-platform header and subs --- !! --------------------------------------------------------- !! --- Start Unix Header and Subs --- !LET UnixFlag= 1 !ASK PIXELS winWid,winHgt !LET winLft= 0 !LET winTop= 0 !LET winRgt= winWid-1 !LET winBas= winHgt-1 !SET WINDOW 0,winRgt,winBas,0 !CALL Palette ! !CALL ToolPanel !CALL ThisProgram ! !END !EXTERNAL ! !MODULE UnixParts ! SHARE CharWidth ! ! SUB SetTextFont(font,size,style$) ! LET font$= "-adobe-courier-" ! IF style$= "normal" then ! LET style$= "medium-r-normal--" ! ELSE ! LET style$= "bold-r-normal--" ! END IF ! IF size=9 then ! LET size$= str$(10) ! ELSE ! LET size$= str$(size) ! END IF ! LET test= SetFont(font$&style$&size$&"*") ! ! IF size=9 then ! LET CharWidth= 6 ! ELSE IF size=12 then ! numeric output - axis labels ! LET CharWidth= 7 ! ELSE IF size=14 then ! rare ! LET CharWidth= 8 ! ELSE IF size=18 then ! rare ! LET CharWidth= 10 ! END IF ! END SUB ! ! SUB StringWidth(sw$,sl) ! string width in pixels ! ! LET sl= StrWidth(sw$) ! LET chars= len(sw$) ! LET sl = chars*CharWidth ! END SUB ! ! SUB SetLineWeight(wgt) ! ! CALL PenSize(wgt,wgt) ! END SUB ! ! SUB BoxDisk(Lft,Rgt,Bas,Top) ! CALL Fill_Circle(Lft,Rgt,Bas,Top) ! END SUB !END MODULE !! ------ End of TB Unix Header and Subs ------ !! --------------------------------------------------------- ! *** Fourier Coefficients tool SUB FourierCoefficients DECLARE PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white DECLARE PUBLIC red,yellow,green,cyan,blue,magenta,colorscheme DECLARE PUBLIC slideClr DECLARE PUBLIC workLft,workRgt,workBas,workTop,workMidx DECLARE PUBLIC axislabelclr,axisclr,true,false DECLARE DEF quitWithin, infoWithin ! --- help screen array --- DIM info$(1:1) MAT READ info$ DATA "Information on Fourier Series" ! ---------- Utility functions --- DECLARE DEF clamp,roundn,e ! --------- data arrays and functions ---------- DIM Temp(0:12) ! temporary storage DIM At(0:12), Bt(0:12) ! dimension the target vector DIM As(0:12), Bs(0:12) ! dimension the slider vector DIM ParamA(0:12), ParamB(0:12) ! parameter values from sliders SUB Fourier(t,k,x) SELECT CASE funcFlag CASE 1 ! sine SELECT CASE termFlag CASE 1 ! all LET t1= c1*(sin( 1*t)) LET t2= c2*(sin( 2*t)) LET t3= c3*(sin( 3*t)) LET t4= c4*(sin( 4*t)) LET t5= c5*(sin( 5*t)) LET t6= c6*(sin( 6*t)) CASE 2 ! odd LET t1= c1*(sin( 1*t)) LET t2= c2*(sin( 3*t)) LET t3= c3*(sin( 5*t)) LET t4= c4*(sin( 7*t)) LET t5= c5*(sin( 9*t)) LET t6= c6*(sin(11*t)) CASE 3 ! even LET t1= c1*(sin( 2*t)) LET t2= c2*(sin( 4*t)) LET t3= c3*(sin( 6*t)) LET t4= c4*(sin( 8*t)) LET t5= c5*(sin(10*t)) LET t6= c6*(sin(12*t)) END SELECT LET sum= t1 + t2 + t3 + t4 + t5 + t6 CASE 2 ! cosine SELECT CASE termFlag CASE 1 ! all LET t0= c0/2 ! *(cos( 0*t)) LET t1= c1*(cos( 1*t)) LET t2= c2*(cos( 2*t)) LET t3= c3*(cos( 3*t)) LET t4= c4*(cos( 4*t)) LET t5= c5*(cos( 5*t)) LET t6= c6*(cos( 6*t)) CASE 2 ! odd LET t0= 0 ! c0/2 LET t1= c1*(cos( 1*t)) LET t2= c2*(cos( 3*t)) LET t3= c3*(cos( 5*t)) LET t4= c4*(cos( 7*t)) LET t5= c5*(cos( 9*t)) LET t6= c6*(cos(11*t)) CASE 3 ! even LET t0= c0/2 ! *(cos( 0*t)) LET t1= c1*(cos( 2*t)) LET t2= c2*(cos( 4*t)) LET t3= c3*(cos( 6*t)) LET t4= c4*(cos( 8*t)) LET t5= c5*(cos(10*t)) LET t6= c6*(cos(12*t)) END SELECT LET sum= t0 + t1 + t2 + t3 + t4 + t5 + t6 END SELECT LET x = k * sum END SUB SUB FourierTerm(slider,t,x) SELECT CASE funcFlag CASE 1 ! sine SELECT CASE termFlag CASE 1 ! all SELECT CASE slider CASE 1 ! not needed for sine CASE 2 LET x= c1*(sin( 1*t)) CASE 3 LET x= c2*(sin( 2*t)) CASE 4 LET x= c3*(sin( 3*t)) CASE 5 LET x= c4*(sin( 4*t)) CASE 6 LET x= c5*(sin( 5*t)) CASE 7 LET x= c6*(sin( 6*t)) END SELECT CASE 2 ! odd SELECT CASE slider CASE 1 ! not needed for sine CASE 2 LET x= c1*(sin( 1*t)) CASE 3 LET x= c2*(sin( 3*t)) CASE 4 LET x= c3*(sin( 5*t)) CASE 5 LET x= c4*(sin( 7*t)) CASE 6 LET x= c5*(sin( 9*t)) CASE 7 LET x= c6*(sin(11*t)) END SELECT CASE 3 ! even SELECT CASE slider CASE 1 ! not needed for sine CASE 2 LET x= c1*(sin( 2*t)) CASE 3 LET x= c2*(sin( 4*t)) CASE 4 LET x= c3*(sin( 6*t)) CASE 5 LET x= c4*(sin( 8*t)) CASE 6 LET x= c5*(sin(10*t)) CASE 7 LET x= c6*(sin(12*t)) END SELECT END SELECT CASE 2 ! cosine SELECT CASE termFlag CASE 1 ! all SELECT CASE slider CASE 1 LET x= c0/2 CASE 2 LET x= c1*(cos( 1*t)) CASE 3 LET x= c2*(cos( 2*t)) CASE 4 LET x= c3*(cos( 3*t)) CASE 5 LET x= c4*(cos( 4*t)) CASE 6 LET x= c5*(cos( 5*t)) CASE 7 LET x= c6*(cos( 6*t)) END SELECT CASE 2 ! odd SELECT CASE slider CASE 1 ! not needed for odd CASE 2 LET x= c1*(cos( 1*t)) CASE 3 LET x= c2*(cos( 3*t)) CASE 4 LET x= c3*(cos( 5*t)) CASE 5 LET x= c4*(cos( 7*t)) CASE 6 LET x= c5*(cos( 9*t)) CASE 7 LET x= c6*(cos(11*t)) END SELECT CASE 3 ! even SELECT CASE slider CASE 1 LET x= c0/2 CASE 2 LET x= c1*(cos( 2*t)) CASE 3 LET x= c2*(cos( 4*t)) CASE 4 LET x= c3*(cos( 6*t)) CASE 5 LET x= c4*(cos( 8*t)) CASE 6 LET x= c5*(cos(10*t)) CASE 7 LET x= c6*(cos(12*t)) END SELECT END SELECT END SELECT END SUB ! current target functions - best approximations of the target models ! DEF f1(t)= [ 0 +(1/1)*sin(1*t)+(1/3)*sin(3*t)+(1/5) *sin(5*t) +(1/7) *sin(7*t) +(1/9) *sin(9*t) +(1/11) *sin(11*t)] ! DEF f2(t)= [ 0 +(1/1)*cos(1*t)-(1/3)*cos(3*t)+(1/5) *cos(5*t) -(1/7) *cos(7*t) +(1/9) *cos(9*t) -(1/11) *cos(11*t)] ! DEF f3(t)= [ pi^2/8-(1/1)*cos(1*t)-(1/9)*cos(3*t)-(1/25)*cos(5*t) -(1/49)*cos(7*t) -(1/81)*cos(9*t) -(1/121)*cos(11*t)] ! DEF f4(t)= [ 0 +(1/1)*sin(1*t)-(1/2)*sin(2*t)+(1/3) *sin(3*t) -(1/4) *sin(4*t) +(1/5) *sin(5*t) -(1/6) *sin(6*t) ] ! DEF f5(t)= [ 0 +(1/1)*sin(2*t)-(1/2)*sin(4*t)+(1/3) *sin(6*t) -(1/4) *sin(8*t) +(1/5) *sin(10*t)-(1/6) *sin(12*t)] ! DEF f6(t)= [ pi^2/8-(1/1)*cos(2*t)-(1/9)*cos(6*t)-(1/25)*cos(10*t)-(1/49)*cos(14*t)-(1/81)*cos(18*t)-(1/121)*cos(22*t)] ! 0 1 3 5 7 9 11 ! ---- this method computes the minimum target "distance" --- SUB GetTargetValue(target,D1) MAT At = ZER ! zero the cosine array MAT Bt = ZER ! zero the sine array SELECT CASE target CASE 1 ! target A - square wave - odd sine ! compute terms for the target defined part of the distance value LET Kt = 2 * (pi/4)^2 LET n0= 0 LET Bt( 1),n1 = 1/1 LET Bt( 3),n2 = 1/3 LET Bt( 5),n3 = 1/5 LET Bt( 7),n4 = 1/7 LET Bt( 9),n5 = 1/9 LET Bt(11),n6 = 1/11 CASE 2 ! target B - shifted square - odd cosine LET Kt = 2 * (pi/4)^2 LET At( 0),n0 = 0 LET At( 1),n1 = 1/1 LET At( 3),n2 = -1/3 LET At( 5),n3 = 1/5 LET At( 7),n4 = -1/7 LET At( 9),n5 = 1/9 LET At(11),n6 = -1/11 CASE 3 ! target C LET Kt = 2/3 * (pi^2/4)^2 LET At( 0),n0 = pi^2/4 LET At( 1),n1 = -1/1 LET At( 3),n2 = -1/9 LET At( 5),n3 = -1/25 LET At( 7),n4 = -1/49 LET At( 9),n5 = -1/81 LET At(11),n6 = -1/121 CASE 4 ! target D LET Kt = 2/3 * (pi/2)^2 LET n0= 0 LET Bt( 1),n1 = 1/1 LET Bt( 2),n2 = -1/2 LET Bt( 3),n3 = 1/3 LET Bt( 4),n4 = -1/4 LET Bt( 5),n5 = 1/5 LET Bt( 6),n6 = -1/6 CASE 5 ! target E LET Kt = 2/3 * (pi/2)^2 LET n0= 0 LET Bt( 2),n1 = 1 LET Bt( 4),n2 = -1/2 LET Bt( 6),n3 = 1/3 LET Bt( 8),n4 = -1/4 LET Bt(10),n5 = 1/5 LET Bt(12),n6 = -1/6 CASE 6 ! target F LET Kt = 2/3 * (pi^2/4)^2 LET At( 0),n0 = pi^2/4 LET At( 2),n1 = -1/1 LET At( 6),n2 = -1/9 LET At(10),n3 = -1/25 LET n4= 0 LET n5= 0 LET n6= 0 END SELECT LET t0 = n0^2/2 LET t1 = n1^2 LET t2 = n2^2 LET t3 = n3^2 LET t4 = n4^2 LET t5 = n5^2 LET t6 = n6^2 LET D1 = Kt - (t0+t1+t2+t3+t4+t5+t6) ! target sum END SUB ! ---------- Graphing plane parameters and methods ---------- ! --- plane 1 data --- DECLARE PUBLIC w1Lft,w1Rgt,w1Bas,w1Top,w1Midx,w1Midy DECLARE PUBLIC w1fLft,w1fRgt,w1fBas,w1fTop,w1x0,w1y0 DECLARE PUBLIC w1xFirst, w1xSTik, w1xLTik, w1xLabel, w1xGridstep DECLARE PUBLIC w1yFirst, w1ySTik, w1yLTik, w1yLabel, w1yGridstep DECLARE PUBLIC w1wWid,w1wHgt,w1fWid,w1fHgt DECLARE PUBLIC w1fxRatio,w1fyRatio,w1wxRatio,w1wyRatio,w1Aspect DECLARE PUBLIC w1xPiFlag, w1xMult, w1yPiFlag, w1yMult LET w1Flag = 0 LET w1xPiFlag= 1 LET w1yPiFlag= 0 LET w1xMult = pi LET w1yMult = 1 LET w1Lft = worklft + 55 ! pixel bounds LET w1Rgt = w1Lft + 314 ! 6.28 LET w1Top = worktop + 50 LET w1Bas = w1Top + 300 ! 6.00 LET w1fLft= -1 ! function bounds LET w1fRgt= 1 LET w1fBas= -3 LET w1fTop= 3 LET w1xAx$= "t" ! axis labels LET w1yAx$= "x" LET w1xGridstep= 0.5 ! horizontal grid intervals LET w1yGridstep= 1.0 ! vertical grid intervals LET w1xSTik = 0.5 ! horizontal axis Tik marks LET w1xLTik = 1 LET w1xLabel = 1 LET w1xFirst = w1fLft LET w1ySTik = 0.5 ! vertical axis Tik marks LET w1yLTik = 1 LET w1yLabel = 1 LET w1yFirst = w1fBas ! --- Plane 1 methods --- DECLARE DEF w1Fncx,w1Fncy,w1Wndx,w1Wndy ! window/function transforms DECLARE DEF w1wWithin, w1Within CALL w1Variables SUB w1Init CALL w1DrawPlane(1,1,1) ! x axis, y axis, zeroaxes CALL SetTextFont(1,12,"bold") CALL PlotTextLJ(w1Rgt+8,w1y0+3,w1xAx$,axislabelClr) ! axis labels CALL PlotTextCJ(w1x0,w1Top-10,w1yAx$,axislabelClr) CALL w1KeepGridLayer END SUB ! ---------- Slider parameters and methods ---------- ! ----------- horizontal sliders ------------ LET slideWidth= 200 LET hstep = 64 ! vertical slider spacing LET slideClr = white ! --- horizontal slider 1 --- DECLARE DEF h0Within ! window/function transforms DECLARE PUBLIC h0axis,h0wLft,h0wRgt,h0wBas,h0wTop,h0fLft,h0fRgt DECLARE PUBLIC h0name$,h0form$,h0clr,h0First,h0STik,h0LTik,h0Label DECLARE PUBLIC h0PiAxis,h0Mult,h0fMin,h0fMax,h0wWid,h0fWid LET h0PiAxis= 0 LET h0Mult = 1 LET h0Clr = slideClr LET h0name$ = "" LET h0form$ = "-%.###" LET h0Places= 3 LET h0axis = w1Top LET h0wLft = w1Rgt+120 LET h0wRgt = h0wLft+slideWidth LET h0fLft = -4 ! h0flft LET h0fRgt = 4 ! h0frgt LET h0STik = .5 ! short tick marks LET h0LTik = 1 ! long tick marks LET h0Label= 4 ! labels LET h0First= -4 ! first tick mark LET h0Click= 1 LET h0xPix = (h0fRgt-h0fLft)/slideWidth DECLARE DEF h0LstpWithin,h0RstpWithin CALL h0SliderVariables ! --- Slider 2 --- DECLARE DEF h1Within ! window/function transforms DECLARE PUBLIC h1axis,h1wLft,h1wRgt,h1wBas,h1wTop,h1fLft,h1fRgt DECLARE PUBLIC h1name$,h1form$,h1clr,h1First,h1STik,h1LTik,h1Label DECLARE PUBLIC h1PiAxis,h1Mult,h1fMin,h1fMax LET h1PiAxis= 0 LET h1Mult = 1 LET h1Clr = slideClr LET h1name$ = "" LET h1form$ = "-%.###" LET h1Places= 3 LET h1axis = h0axis+hstep LET h1wLft = h0wLft LET h1wRgt = h1wLft+slidewidth LET h1fLft = -2 LET h1fRgt = 2 LET h1STik = 0.2 LET h1LTik = 1 LET h1Label= 2 LET h1First= -2 LET h1Click= 0.2 LET h1xPix = (h1fRgt-h1fLft)/slideWidth DECLARE DEF h1LstpWithin,h1RstpWithin CALL h1SliderVariables ! --- slider 3 --- DECLARE DEF h2Within ! window/function transforms DECLARE PUBLIC h2axis,h2wLft,h2wRgt,h2wBas,h2wTop,h2fLft,h2fRgt DECLARE PUBLIC h2name$,h2form$,h2clr,h2First,h2STik,h2LTik,h2Label DECLARE PUBLIC h2PiAxis,h2Mult,h2fMin,h2fMax LET h2PiAxis= 0 LET h2Mult = 1 LET h2Clr = slideClr LET h2name$ = "" LET h2form$ = "-%.###" LET h2Places= 3 LET h2axis = h1axis+hstep LET h2wLft = h0wLft LET h2wRgt = h2wLft+slideWidth LET h2fLft = -1 LET h2fRgt = 1 LET h2STik = 0.1 LET h2LTik = 0.5 LET h2Label= 1 LET h2First= -1 LET h2Click= 0.1 LET h2xPix = (h2fRgt-h2fLft)/slideWidth DECLARE DEF h2LstpWithin,h2RstpWithin CALL h2SliderVariables ! --- slider 4 --- DECLARE DEF h3Within ! window/function transforms DECLARE PUBLIC h3axis,h3wLft,h3wRgt,h3wBas,h3wTop,h3fLft,h3fRgt DECLARE PUBLIC h3name$,h3form$,h3clr,h3First,h3STik,h3LTik,h3Label DECLARE PUBLIC h3PiAxis,h3Mult,h3fMin,h3fMax LET h3PiAxis= 0 LET h3Mult = 1 LET h3Clr = slideClr LET h3name$ = "" LET h3form$ = "-%.###" LET h3Places= 3 LET h3axis = h2axis+hstep LET h3wLft = h0wLft LET h3wRgt = h3wLft+slideWidth LET h3fLft = -0.5 LET h3fRgt = 0.5 LET h3STik = 0.1 LET h3LTik = 0.5 LET h3Label= 0.5 LET h3First= -0.5 LET h3Click= 0.1 LET h3xPix = (h3fRgt-h3fLft)/slideWidth DECLARE DEF h3LstpWithin,h3RstpWithin CALL h3SliderVariables ! --- slider 5 --- DECLARE DEF h4Within ! window/function transforms DECLARE PUBLIC h4axis,h4wLft,h4wRgt,h4wBas,h4wTop,h4fLft,h4fRgt DECLARE PUBLIC h4name$,h4form$,h4clr,h4First,h4STik,h4LTik,h4Label DECLARE PUBLIC h4PiAxis,h4Mult,h4fMin,h4fMax LET h4PiAxis= 0 LET h4Mult = 1 LET h4Clr = slideClr LET h4name$ = "" LET h4form$ = "-%.###" LET h4Places= 3 LET h4axis = h3axis+hstep LET h4wLft = h0wLft LET h4wRgt = h4wLft+SlideWidth LET h4fLft = -0.5 LET h4fRgt = 0.5 LET h4STik = 0.1 LET h4LTik = 0.5 LET h4Label= 0.5 LET h4First= -0.5 LET h4Click= 0.1 LET h4xPix = (h4fRgt-h4fLft)/slideWidth DECLARE DEF h4LstpWithin,h4RstpWithin CALL h4SliderVariables ! --- slider 6 --- DECLARE DEF h5Within ! window/function transforms DECLARE PUBLIC h5axis,h5wLft,h5wRgt,h5wBas,h5wTop,h5fLft,h5fRgt DECLARE PUBLIC h5name$,h5form$,h5clr,h5First,h5STik,h5LTik,h5Label DECLARE PUBLIC h5PiAxis,h5Mult,h5fMin,h5fMax LET h5PiAxis= 0 LET h5Mult = 1 LET h5Clr = slideClr LET h5name$ = "" LET h5form$ = "-%.###" LET h5Places= 3 LET h5axis = h4axis+hstep LET h5wLft = h0wLft LET h5wRgt = h5wLft+SlideWidth LET h5fLft = -0.25 LET h5fRgt = 0.25 LET h5STik = 0.05 LET h5LTik = 0.25 LET h5Label= 0.25 LET h5First= -0.25 LET h5Click= 0.05 LET h5xPix = (h5fRgt-h5fLft)/slideWidth DECLARE DEF h5LstpWithin,h5RstpWithin CALL h5SliderVariables ! --- slider 7 --- DECLARE DEF h6Within ! window/function transforms DECLARE PUBLIC h6axis,h6wLft,h6wRgt,h6wBas,h6wTop,h6fLft,h6fRgt DECLARE PUBLIC h6name$,h6form$,h6clr,h6First,h6STik,h6LTik,h6Label DECLARE PUBLIC h6PiAxis,h6Mult,h6fMin,h6fMax LET h6PiAxis= 0 LET h6Mult = 1 LET h6Clr = slideClr LET h6name$ = "" LET h6form$ = "-%.###" LET h6Places= 3 LET h6axis = h5axis+hstep LET h6wLft = h0wLft LET h6wRgt = h6wLft+SlideWidth LET h6fLft = -0.25 LET h6fRgt = 0.25 LET h6STik = 0.05 LET h6LTik = 0.25 LET h6Label= 0.25 LET h6First= -0.25 LET h6Click= 0.05 LET h6xPix = (h6fRgt-h6fLft)/slideWidth DECLARE DEF h6LstpWithin,h6RstpWithin CALL h6SliderVariables ! ------------- Text Boxes ------------- ! ----- t1 - distance value output ----- LET dbasln= workTop+22 LET dlft = w1Lft+30 LET drgt = w1Rgt-20 LET dtop = dbasln-17 LET dbas = dbasln+3 SUB ClearDistance BOX CLEAR dlft,drgt,dbas,dtop END SUB SUB SetDistance IF distFlag=1 then CALL SetTextFont(1,18,"bold") LET n$= using$("-%.#####",D) CALL ClearDistance FOR i= 1 to 8 ! monospace for readability LET ch$= n$(i:i) LET tx = dlft + (i-1)*30 + 5 CALL PlotTextCJ(tx,dbasln,ch$,white) NEXT i END IF END SUB SUB ResetDistance CALL ClearDistance IF target>-1 and distFlag=1 then CALL GetDistance(target,D) CALL SetDistance END IF END SUB ! ----- t2 - Fourier series display ----- LET fstop= workBas-23 LET fsbas= fstop+20 LET fslft= worklft LET fsrgt= workrgt SUB SetFunction CALL ClearFunction IF formFlag=1 then CALL SetTextFont(1,12,"bold") LET txt$ = "x(t) = " SELECT CASE funcFlag CASE 1 SELECT CASE termFlag CASE 1 LET txt1$= "b_[1]sin(t) + b_[2]sin(2t) + b_[3]sin(3t) + b_[4]sin(4t) + b_[5]sin(5t) + b_[6]sin(6t) + ..." CASE 2 LET txt1$= "b_[1]sin(t) + b_[3]sin(3t) + b_[5]sin(5t) + b_[7]sin(7t) + b_[9]sin(9t) + b_[11]sin(11t) + ..." CASE 3 LET txt1$= "b_[2]sin(2t) + b_[4]sin(4t) + b_[6]sin(6t) + b_[8]sin(8t) + b_[10]sin(10t) + b_[12]sin(12t) + ..." END SELECT CASE 2 SELECT CASE termFlag CASE 1 LET txt1$= "a_[0](0.5) + a_[1]cos(t) + a_[2]cos(2t) + a_[3]cos(3t) + a_[4]cos(4t) + a_[5]cos(5t) + a_[6]cos(6t) + ..." CASE 2 LET txt1$= "a_[1]cos(t) + a_[3]cos(3t) + a_[5]cos(5t) + a_[7]cos(7t) + a_[9]cos(9t) + a_[11]cos(11t) + ..." CASE 3 LET txt1$= "a_[0](0.5) + a_[2]cos(2t) + a_[4]cos(4t) + a_[6]cos(6t) + a_[8]cos(8t) + a_[10]cos(10t) + a_[12]cos(12t) + ..." END SELECT END SELECT CALL SuperSubScriptLJ(w1Lft,fsbas-8,txt$&txt1$,white) END IF END SUB SUB ClearFunction BOX CLEAR fslft,fsrgt,fsbas,fstop END SUB ! -------- Radio Boxes -------- ! ---- r1 - Series --- DECLARE PUBLIC r1cnt,r1stp,r1siz DECLARE PUBLIC r1lft,r1rgt,r1bas,r1top,r1Name$,r1NameClr DECLARE PUBLIC r1NameList$(),r1ColorList() MAT redim r1NameList$(1:2) MAT READ r1NameList$ DATA "Sine Series", "Cosine Series" MAT redim r1ColorList(1:2) MAT READ r1ColorList DATA 5,5 LET r1cnt = 2 LET r1Lft = w1Rgt - 120 LET r1Top = w1Bas + 35 LET r1Name$ = "" LET r1NameClr= 5 DECLARE DEF r1Within CALL r1SetVars ! ---- r2 - Terms --- DECLARE PUBLIC r2cnt,r2stp,r2siz DECLARE PUBLIC r2lft,r2rgt,r2bas,r2top,r2Name$,r2NameClr DECLARE PUBLIC r2NameList$(),r2ColorList() MAT redim r2NameList$(1:3) MAT READ r2NameList$ DATA "All terms", "Odd terms", "Even terms" MAT redim r2ColorList(1:3) MAT READ r2ColorList DATA 5,5,5 LET r2cnt = 3 LET r2Lft = r1Lft LET r2Top = r1Top + 3*r2stp LET r2Name$ = "" LET r2NameClr= 5 DECLARE DEF r2Within CALL r2SetVars ! --- r3 - Models --- DECLARE PUBLIC r3cnt,r3stp,r3siz DECLARE PUBLIC r3lft,r3rgt,r3bas,r3top,r3Name$,r3NameClr DECLARE PUBLIC r3NameList$(),r3ColorList() MAT redim r3NameList$(1:6) MAT READ r3NameList$ DATA "A", "B", "C", "D", "E", "F" MAT redim r3ColorList(1:6) MAT READ r3ColorList DATA 5,5,5,5,5,5 LET r3cnt = 6 LET r3Lft = r1Lft - 65 LET r3Top = r1Top LET r3Name$ = "" LET r3NameClr= 5 DECLARE DEF r3Within CALL r3SetVars ! --- checkbox - series formula --- DECLARE PUBLIC cb1Lft,cb1Rgt,cb1Bas,cb1Top,cb1Txt$,cb1Clr,cb1State DECLARE DEF cb1Within LET cb1Lft = w1Lft LET cb1Bas = r2Top + r2siz LET cb1Txt$= "Formula" LET cb1Clr = litgry CALL cb1Variables ! --- checkbox - distance value --- DECLARE PUBLIC cb2Lft,cb2Rgt,cb2Bas,cb2Top,cb2Txt$,cb2Clr,cb2State DECLARE DEF cb2Within LET cb2Lft = cb1Lft LET cb2Bas = cb1Bas + 18 LET cb2Txt$= "Distance" LET cb2Clr = litgry CALL cb2Variables SUB distButton(target) CALL SetTextFont(1,12,"bold") IF target>-1 then CALL cb2Init IF chkFlag=1 then ! SLU CALL DrawButton(cklft,ckrgt,ckbas,cktop,5,"Check") END IF ELSE BOX CLEAR cb2Lft,cb2Lft+100,cb2Bas,cb2Top IF chkFlag=1 then BOX CLEAR cklft,ckrgt,ckbas,cktop END IF END SUB ! ----- Buttons ----- SUB Buttons CALL SetTextFont(1,12,"bold") LET bhgt= 18 LET clft= w1Lft LET crgt= clft+75 LET ctop= w1bas+35 LET cbas= ctop+bhgt CALL DrawButton(clft,crgt,cbas,ctop,5,"Clear") LET zlft= cLft LET zrgt= cRgt LET ztop= cBas + 2 LET zbas= ztop+bhgt CALL DrawButton(zlft,zrgt,zbas,ztop,5,"Reset") END SUB ! ----- SLU only - check buttons for setting exact values --- DIM targetValues(1:6,0:6) MAT READ targetValues DATA 0, 1, 0.333333, 0.200000, 0.142857, 0.111111, 0.090909 DATA 0, 1,-0.333333, 0.200000,-0.142857, 0.111111,-0.090909 DATA 2.467401,-1, 0 ,-0.111111, 0 ,-0.040000, 0 !-0.020408,-0.012346,-0.008264 DATA 0, 1,-0.500000, 0.333333,-0.250000, 0.200000,-0.166667 !DATA 0, 0, 1 , 0 ,-0.500000, 0, 0.333333 !, 0 !-0.250000, 0.200000,-0.166667 DATA 0, 1,-0.500000, 0.333333,-0.250000, 0.200000, -0.166667 DATA 2.467401,-1, 0 ,-0.111111, 0 ,-0.040000, 0 !-0.020408,0,-0.012346,0,-0.008264 LET cklft = h0wLft-85 LET ckrgt = cklft+50 LET cktop = workbas-55 LET ckbas = cktop+18 LET hboxlft= cklft+19 LET hboxrgt= hboxlft+12 SUB CheckButtonsDraw IF funcFlag=2 and termFlag<>2 then CALL DrawButton(hboxlft,hboxrgt,h0wBas-2,h0wBas-14,0,"") END IF CALL DrawButton(hboxlft,hboxrgt,h1wBas-2,h1wBas-14,0,"") CALL DrawButton(hboxlft,hboxrgt,h2wBas-2,h2wBas-14,0,"") CALL DrawButton(hboxlft,hboxrgt,h3wBas-2,h3wBas-14,0,"") CALL DrawButton(hboxlft,hboxrgt,h4wBas-2,h4wBas-14,0,"") CALL DrawButton(hboxlft,hboxrgt,h5wBas-2,h5wBas-14,0,"") CALL DrawButton(hboxlft,hboxrgt,h6wBas-2,h6wBas-14,0,"") END SUB SUB CheckButtonsClear ! SLU BOX CLEAR hboxlft,hboxrgt,h6wbas+15,h0wtop-5 END SUB ! --- end of design and layout --- ! --- set default parameters --- LET funcFlag= 1 LET termFlag= 1 LET target = -1 LET r1num = 1 LET r2num = 1 LET r3num = 0 LET distFlag= 0 LET formFlag= 0 LET chkFlag = 0 ! SLU LET k = 1 LET c0,c1,c2,c3,c4,c5,c6,c7= 0 ! --- Draw the screen --- CALL InitScreen SUB InitScreen BOX CLEAR worklft,workrgt,workbas,worktop CALL w1Init CALL DrawModel(target) CALL Buttons CALL cb1Init CALL r1DrawCheckBoxes CALL r1SetCheckBox(r1num) CALL r2DrawCheckBoxes CALL r2SetCheckBox(r2num) CALL r3DrawCheckBoxes IF target>0 then CALL r3SetCheckBox(r3num) CALL SetFunction CALL DrawSliders(0) CALL ReDraw END SUB ! ----------------- Event manager ----------------- DO CALL MouseDown(mx,my,ms) LET oldx= -99999 IF h0Flag=true and h0Within(mx,my)=true then IF myckLft and mxckTop and myhboxlft and mxh0wtop and myh0wTop and myh1wTop and myh2wTop and myh3wTop and myh4wTop and myh5wTop and myh6wTop and mycLft and mxcTop and myzLft and mxzTop and myoldn then CALL DrawTerm(5,eq) CALL DrawGraph(5,0) CALL ResetDistance LET oldn= n END IF END SUB ! --- SUB h0MouseClick CALL h0GetClickVal(ms,h0Click,c0) CALL ClickAction(c0,oldc0) END SUB SUB h0MouseDrag DO CALL h0GetDragVal(ms,h0Places,c0) CALL DragAction(c0,oldc0,1) LOOP until ms=3 CALL DrawGraph(1,1) END SUB ! --- SUB h1MouseClick CALL h1GetClickVal(ms,h1Click,c1) CALL ClickAction(c1,oldc1) END SUB SUB h1MouseDrag DO CALL h1GetDragVal(ms,h1Places,c1) CALL DragAction(c1,oldc1,2) LOOP until ms=3 CALL DrawGraph(1,1) END SUB ! --- SUB h2MouseClick CALL h2GetClickVal(ms,h2Click,c2) CALL ClickAction(c2,oldc2) END SUB SUB h2MouseDrag DO CALL h2GetDragVal(ms,h2Places,c2) CALL DragAction(c2,oldc2,3) LOOP until ms=3 CALL DrawGraph(1,1) END SUB ! --- SUB h3MouseClick CALL h3GetClickVal(ms,h3Click,c3) CALL ClickAction(c3,oldc3) END SUB SUB h3MouseDrag DO CALL h3GetDragVal(ms,h3Places,c3) CALL DragAction(c3,oldc3,4) LOOP until ms=3 CALL DrawGraph(1,1) END SUB ! --- SUB h4MouseClick CALL h4GetClickVal(ms,h4Click,c4) CALL ClickAction(c4,oldc4) END SUB SUB h4MouseDrag DO CALL h4GetDragVal(ms,h4Places,c4) CALL DragAction(c4,oldc4,5) LOOP until ms=3 CALL DrawGraph(1,1) END SUB ! --- SUB h5MouseClick CALL h5GetClickVal(ms,h5Click,c5) CALL ClickAction(c5,oldc5) END SUB SUB h5MouseDrag DO CALL h5GetDragVal(ms,h5Places,c5) CALL DragAction(c5,oldc5,6) LOOP until ms=3 CALL DrawGraph(1,1) END SUB ! --- SUB h6MouseClick CALL h6GetClickVal(ms,h6Click,c6) CALL ClickAction(c6,oldc6) END SUB SUB h6MouseDrag DO CALL h6GetDragVal(ms,h6Places,c6) CALL DragAction(c6,oldc6,7) LOOP until ms=3 CALL DrawGraph(1,1) END SUB ! --------- slider management methods ---------- SUB ZeroSliders LET k= 1 LET c0,c1,c2,c3,c4,c5,c6,c7= 0 MAT ParamA= ZER MAT ParamB= ZER IF funcFlag=2 and termFlag<>2 then CALL h0Mark(c0) CALL h1Mark(c1) CALL h2Mark(c2) CALL h3Mark(c3) CALL h4Mark(c4) CALL h5Mark(c5) CALL h6Mark(c6) END SUB SUB KeepAOdd ! cosine FOR i= 0 to 12 step 2 LET ParamA(i)= 0 NEXT i END SUB SUB KeepAEven ! cosine FOR i= 1 to 11 step 2 LET ParamA(i)= 0 NEXT i END SUB SUB KeepBOdd ! sine FOR i= 0 to 12 step 2 LET ParamB(i)= 0 NEXT i END SUB SUB KeepBEven ! sine FOR i= 1 to 11 step 2 LET ParamB(i)= 0 NEXT i END SUB SUB SliderValues SELECT CASE termFlag CASE 1 ! all LET Temp( 1) = c1 LET Temp( 2) = c2 LET Temp( 3) = c3 LET Temp( 4) = c4 LET Temp( 5) = c5 LET Temp( 6) = c6 LET Temp( 7) = c7 CASE 2 ! odd LET Temp( 1) = c1 LET Temp( 3) = c2 LET Temp( 5) = c3 LET Temp( 7) = c4 LET Temp( 9) = c5 LET Temp(11) = c6 CASE 3 ! even LET Temp( 2) = c1 LET Temp( 4) = c2 LET Temp( 6) = c3 LET Temp( 8) = c4 LET Temp(10) = c5 LET Temp(12) = c6 END SELECT END SUB SUB StoreSliderVars MAT ParamB= ZER MAT ParamA= ZER MAT Temp = ZER CALL SliderValues IF funcflag=1 then MAT ParamB = temp ELSE LET Temp(0)= c0 MAT ParamA = temp END IF END SUB SUB DrawSliders(reset) BOX CLEAR h0wlft-30,h0wrgt+80,h6wbas+20,h0wtop-5 CALL CheckButtonsClear IF reset=1 then LET k= 1 LET c0,c1,c2,c3,c4,c5,c6,c7= 0 MAT ParamA= ZER MAT ParamB= ZER END IF IF funcFlag=1 then ! sine LET h0Flag= 0 MAT Temp = ParamB LET s$ = "b_" ELSE ! cosine IF termFlag<>2 then LET h0Flag= 1 ELSE LET h0Flag= 0 END IF MAT Temp = ParamA LET s$ = "a_" END IF SELECT CASE termFlag CASE 1 ! all LET h0= 4 LET h1= 2 LET h2= 2 LET h3= 1 LET h4= 1 LET h5= 0.5 LET h6= 0.5 CALL ResetSliderVars LET c0= Temp(0) LET c1= Temp(1) LET c2= Temp(2) LET c3= Temp(3) LET c4= Temp(4) LET c5= Temp(5) LET c6= Temp(6) IF funcFlag=2 then CALL h0DrawSlider(s$ & "[ 0]",c0) CALL h1DrawSlider(s$ & "[ 1]",c1) CALL h2DrawSlider(s$ & "[ 2]",c2) CALL h3DrawSlider(s$ & "[ 3]",c3) CALL h4DrawSlider(s$ & "[ 4]",c4) CALL h5DrawSlider(s$ & "[ 5]",c5) CALL h6DrawSlider(s$ & "[ 6]",c6) CASE 2 ! odd LET h1= 2 LET h2= 1 LET h3= 0.5 LET h4= 0.5 LET h5= 0.25 LET h6= 0.25 CALL ResetSliderVars LET c1= Temp( 1) LET c2= Temp( 3) LET c3= Temp( 5) LET c4= Temp( 7) LET c5= Temp( 9) LET c6= Temp(11) CALL h1DrawSlider(s$ & "[ 1]",c1) CALL h2DrawSlider(s$ & "[ 3]",c2) CALL h3DrawSlider(s$ & "[ 5]",c3) CALL h4DrawSlider(s$ & "[ 7]",c4) CALL h5DrawSlider(s$ & "[ 9]",c5) CALL h6DrawSlider(s$ & "[11]",c6) CASE 3 ! even LET h0= 4 LET h1= 2 LET h2= 1 LET h3= 0.5 LET h4= 0.5 LET h5= 0.25 LET h6= 0.25 CALL ResetSliderVars LET c0= Temp( 0) LET c1= Temp( 2) LET c2= Temp( 4) LET c3= Temp( 6) LET c4= Temp( 8) LET c5= Temp(10) LET c6= Temp(12) IF funcFlag=2 then CALL h0DrawSlider(s$ & "[ 0]",c0) CALL h1DrawSlider(s$ & "[ 2]",c1) CALL h2DrawSlider(s$ & "[ 4]",c2) CALL h3DrawSlider(s$ & "[ 6]",c3) CALL h4DrawSlider(s$ & "[ 8]",c4) CALL h5DrawSlider(s$ & "[10]",c5) CALL h6DrawSlider(s$ & "[12]",c6) END SELECT IF h0Flag=1 then CALL h0StepButtons CALL h1StepButtons CALL h2StepButtons CALL h3StepButtons CALL h4StepButtons CALL h5StepButtons CALL h6StepButtons END SUB SUB ResetSliderVars ! h1= 2 LET h1fLft = -h1 LET h1fRgt = h1 LET h1Label= h1 LET h1STik = 0.2 LET h1LTik = 1 ! h2= 1,2 LET h2fLft = -h2 LET h2fRgt = h2 LET h2Label= h2 IF h2=1 then LET h2STik = 0.1 LET h2LTik = 0.5 ELSE LET h2STik = 0.2 LET h2LTik = 1 END IF ! h3= .5,1 LET h3fLft = -h3 LET h3fRgt = h3 LET h3Label= h3 IF h3=.5 then LET h3STik = 0.1 LET h3LTik = 0.5 ELSE LET h3STik = 0.1 LET h3LTik = 0.5 END IF ! h4= .5,1 LET h4fLft = -h4 LET h4fRgt = h4 LET h4Label= h4 IF h4=.5 then LET h4STik = 0.1 LET h4LTik = 0.5 ELSE LET h4STik = 0.1 LET h4LTik = 0.5 END IF ! h5= .25,.5 LET h5fLft = -h5 LET h5fRgt = h5 LET h5Label= h5 IF h5=.5 then LET h5STik = 0.1 LET h5LTik = 0.5 ELSE LET h5STik = 0.05 LET h5LTik = 0.25 END IF ! h6= .25,.5 LET h6fLft = -h6 LET h6fRgt = h6 LET h6Label= h6 IF h6=.5 then LET h6STik = 0.1 LET h6LTik = 0.5 ELSE LET h6STik = 0.05 LET h6LTik = 0.25 END IF LET h0First= h0fLft LET h1First= h1fLft LET h2First= h2fLft LET h3First= h3fLft LET h4First= h4fLft LET h5First= h5fLft LET h6First= h6fLft LET h0Click= h0STik LET h1Click= h1STik LET h2Click= h2STik LET h3Click= h3STik LET h4Click= h4STik LET h5Click= h5STik LET h6Click= h6STik CALL h0SliderVariables CALL h1SliderVariables CALL h2SliderVariables CALL h3SliderVariables CALL h4SliderVariables CALL h5SliderVariables CALL h6SliderVariables LET h1xPix = (h1fRgt-h1fLft)/slideWidth LET h2xPix = (h2fRgt-h2fLft)/slideWidth LET h3xPix = (h3fRgt-h3fLft)/slideWidth LET h4xPix = (h4fRgt-h4fLft)/slideWidth LET h5xPix = (h5fRgt-h5fLft)/slideWidth LET h6xPix = (h6fRgt-h6fLft)/slideWidth END SUB ! --- Graphing Methods --- SUB ReDraw CALL ResetDistance CALL DrawGraph(1,1) END SUB ! --- This draws the graph of the sum of the terms --- SUB DrawGraph(stp,refresh) IF refresh=1 then CALL w1ShowGraphLayer SET COLOR yellow FOR wx= w1Lft to w1Rgt step stp LET t= w1Fncx(wx) CALL Fourier(t,k,x) LET wy= w1Wndy(x) IF wy>w1Top and wyw1Top and wy=0 then LET wxnh= w1Wndx(-0.5*pi) ! negative half pi LET wxph= w1Wndx( 0.5*pi) ! positive half pi SET COLOR green SELECT CASE target CASE 1 ! square - odd sine LET wyn1= w1Wndy(-pi/4) ! negative LET wyp1= w1Wndy( pi/4) ! positive PLOT w1Lft,wyn1; w1x0,wyn1; w1x0,wyp1; w1Rgt,wyp1 CASE 2 ! square - odd cosine LET wyn1= w1Wndy(-pi/4) ! negative LET wyp1= w1Wndy( pi/4) ! positive PLOT w1Lft,wyn1; wxnh,wyn1; wxnh,wyp1; wxph,wyp1; wxph,wyn1; w1Rgt,wyn1 CASE 3 ! v - inverse cosine LET wyn1= w1Wndy(-pi^2/4) ! negative LET wyp1= w1Wndy( pi^2/4) ! positive PLOT w1Lft,wyp1; w1x0,w1y0; w1Rgt,wyp1 CASE 4 ! sawtooth? - all sine LET wyn1= w1Wndy(-pi/2) ! negative LET wyp1= w1Wndy( pi/2) ! positive PLOT w1Lft,wyn1; w1Rgt,wyp1 CASE 5 ! LET wyn1= w1Wndy(-pi/2) ! negative LET wyp1= w1Wndy( pi/2) ! positive PLOT w1Lft,w1y0; wxnh,wyp1; wxnh,wyn1; wxph,wyp1; wxph,wyn1; w1Rgt,w1y0 CASE 6 LET wyn1= w1Wndy(-pi^2/4) ! negative LET wyp1= w1Wndy( pi^2/4) ! positive PLOT w1Lft,w1y0; wxnh,wyp1; w1x0,w1y0; wxph,wyp1; w1Rgt,w1y0 END SELECT END IF CALL w1KeepGraphLayer END SUB END SUB ! ----- end of Fourier Coefficients -----