!Plunger amp phase: OK, this seems to be behaving correctly. !This choice of notation and of limits seems fine. The blue !plunger looks good. ! !I like the background color on this one, by the way, at least on my !bizarro lcd screen. ! !- I would like to see the phi scale measured in multiples of pi ; !something we've been putting off. And, as in the tides tool, the label !should be - phi, perhaps placed below as it is in Tides. ! !- Do you think that the struts you used in Tides would be effective !here, in the A and -phi windows? ! !- The bottom window should be labeled k/p(i omega) , and the legend !at the top should have something added: ! !p(D)x = x" + etc as it is. ! !- On my screen at least the letters come in two tones: omega bright, !and the value of omega pale; b and its values are both pale. I don't !know what's causing this. ! !- On the tides tool we make a color distinction between t_0 and phi, !and state the relationship. I think we should do that here too; so !add a t_0 = ... calculation exactly as in the Tides tool. Also P !just as in Tides. On both tools each of these might look good written !in a single line (but I don't understand all the typsetting issues here). !OK, we're going in circles a little bit here. !We started with k, and then I was suggesting replacing !it with w_n^2. We can go back to k, for the moment !anyway. But it could go out to 16, I since it is to !be compared to omega^2. It's exciting to see the nice !resonance peak. In addition to that it's important to display !some case in which b^2 = 2k. If we keep b between .5 and 1.5 !this occurs with w_n between about .36 and 1.0: restrricted, !but on the screen. ! !Would it make sense to color code the plunger with the signal !curve (which is blue)? ! !Both w_n and k still show up in the legend. The equation is ! !x" + bx' + kx = k cos(wt) ! !or what is the same ! !x" + bx' + w_n^2 x = w_n^2 cos(wt). !! File: VibrationAmpPhs.MIT !! Sept 29, 2001 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 qLft,qRgt,qBas,qTop PUBLIC infLft,infRgt,infBas,infTop PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white PUBLIC red,yellow,green,cyan,blue,magenta,colorscheme PUBLIC planeclr,gridclr,rimclr,axisclr,axislabelclr,titleclr,rightsclr PUBLIC numberlineclr,slotdrkclr,slotlgtclr,slideclr PUBLIC largefonts PUBLIC title$ LET toolHgt= 540 LET toolWid= 780 LET window$= "MIT Visual Math Project" LET colorscheme= 0 LET title$ = "Vibration: Amplitude and Phase Response" SUB ThisProgram CALL VibrationAmplitude END SUB !! ---------------------------------------------------------- !! --- 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 !CLEAR ! !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 ! --------------------------------------------------------- !! --- Start Mac TB4 Header and Subs --- !LET M68Kflag = 1 !LIBRARY "MacTools*" !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 !CLEAR ! !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 Mac4 Header and Subs --- ! --------------------------------------------------------- ! ! --- Start Cross-Platform TB5 header and subs --- ! LIBRARY "c:\TB Silver\TBLibs\TrueCtrl.trc" ! windows !LIBRARY "c:\TBGold\TBLibs\TrueCtrl.trc" ! windows !LIBRARY "c:\program files\TB Gold\TBLIbs\TrueCtrl.trc" ! windows !LIBRARY ":TBLibs:TrueCtrl.trc" ! macintosh PUBLIC old_priority LET new_priority= 19200 ! 9600 is default CALL Priority(new_priority,old_priority) PUBLIC WinID DECLARE PUBLIC OBJM_SET,OBJM_SYSINFO LET winHgt= toolHgt LET winWid= toolWid LET WinID = 0 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 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 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 CALL Object(OBJM_SET, WinID, "SOLID MIX", "", values()) CALL TC_Win_RealizePalette(WinID) ! PC needs this in 5.1 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 CLEAR 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= 7 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= 8 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$= "Arial" 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 header and subs --- !! --------------------------------------------------------- MODULE Interface DECLARE PUBLIC PCflag,M68kflag,Mac5flag,Unixflag,xmax,ymax DECLARE PUBLIC toolLft,toolRgt,toolBas,toolTop,toolhdr,toolHgt,toolWid ! tool boundaries DECLARE PUBLIC winLft,winRgt,winBas,winTop,winHgt,winWid ! window DECLARE PUBLIC workLft,workRgt,workBas,workTop,workMidx ! work area DECLARE PUBLIC qLft,qRgt,qBas,qTop DECLARE PUBLIC infLft,infRgt,infBas,infTop DECLARE PUBLIC iLft,iRgt,iBas,iTop DECLARE PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white DECLARE PUBLIC red,yellow,green,cyan,blue,magenta,colorscheme DECLARE PUBLIC planeclr,gridclr,rimclr,axisclr,axislabelclr,titleclr,rightsclr DECLARE PUBLIC numberlineclr,slotdrkclr,slotlgtclr,slideclr,headerclr,btnclr DECLARE PUBLIC largefonts DECLARE PUBLIC title$ SUB ToolPanel LET toolLft= int((winWid-toolWid)/2) LET toolRgt= toolLft+toolWid-1 LET toolTop= int((winHgt-toolHgt)/2) LET toolBas= toolTop+toolHgt-1 LET toolhdr= toolTop+27 LET toolmid= int((toolLft+toolRgt)/2) IF M68kFlag=1 or Unixflag=1 then ASK PIXELS xpix,ypix LET xmax= xpix-1 LET ymax= ypix-1 SET COLOR drkgry BOX AREA 0,xmax,ymax,0 CALL Rim(toolLft,toolRgt,toolBas,toolTop,0) ELSE SET COLOR white BOX LINES toollft,toolrgt,toolbas,tooltop END IF CALL HRule(toollft+4,toolrgt-4,toolhdr,3,0) LET workLft = toolLft+ 5 LET workRgt = toolRgt- 5 LET workTop = toolhdr+ 2 LET workBas = toolBas- 5 LET workMidx= int((workLft+workRgt)/2) CALL SetTextFont(1,9,"bold") LET qLft= toolRgt-40 LET qTop= toolTop+5 LET qRgt= qLft+35 LET qBas= qTop+17 CALL DrawButton(qLft,qRgt,qBas,qTop,5,"Quit") LET infLft= qLft - 40 ! info button LET infTop= qTop LET infRgt= infLft + 35 LET infBas= qBas CALL DrawButton(infLft,infRgt,infBas,infTop,5,"Help") CALL SetToolTitle(title$) ! LET cl= toolLft + 30 ! LET cr= toolRgt - 30 ! LET cy= workBas+2 ! SET COLOR white ! PLOT cl,cy-1; cr,cy-1 ! SET COLOR black ! PLOT cl+1,cy; cr+1,cy !CALL CopyRight(workLft+30,cy+9,rightsclr) END SUB SUB SetToolTitle(txt$) !BOX CLEAR qRgt+5,infLft-5,toolhdr-5,toolTop+5 CALL SetTextFont(1,12,"bold") CALL PlotTextLJ(workLft+20,toolhdr-10,txt$,titleclr) END SUB SUB CopyRight(hp,yp,c) ! Width = 87 pixels ! Width = 131 pixels LET x= hp LET y= yp-7 SET COLOR c FOR v= 0 to 7 READ data$ FOR h= 0 to 30 LET n$= data$(h:h) IF n$= "1" then PLOT x+h,y+v END IF NEXT h NEXT v DATA 00111100000000000000000000000 DATA 01000010000110001100011000100 DATA 10011001001001010010100101100 DATA 10100001000001010010100100100 DATA 10100001000010010010100100100 DATA 10011001000100010010100100100 DATA 01000010001111001100011001110 DATA 00111100000000000000000000000 LET x= x+35 FOR v= 1 to 7 READ data$ FOR h= 1 to 33 LET n$= data$(h:h) IF n$= "1" then PLOT x+h,y+v-1 END IF NEXT h NEXT v DATA 10001000010001000000010000000000 DATA 10001000010001000000010000000000 DATA 10001000010001001110010110010110 DATA 11111000011111010001011001011001 DATA 10001000010001010001010001010001 DATA 10001000010001010001010001010001 DATA 10001010010001001110010001010001 LET x= x+36 FOR v= 1 to 7 READ data$ FOR h= 1 to 68 LET n$= data$(h:h) IF n$= "1" then PLOT x+h,y+v-1 END IF NEXT h NEXT v DATA 00000000000000001000010001000010001001001001000000000000 DATA 00000000000000001000010001000011011000001001000000000000 DATA 00111010110001111000010001000010101001001001000111001011 DATA 01001011001010001000011111000010101001001001001000101100 DATA 10001010001010001000010001000010001001001001001111101000 DATA 10011010001010001000010001000010001001001001001000001000 DATA 01101010001001111000010001010010001001001001000111001000 END SUB SUB Rim(l,r,b,t,c) SET COLOR 0 BOX AREA l,r,b,t SET COLOR black PLOT l+3,b-3; l+3,t+3; r-3,t+3 PLOT l+1,b; r,b; r,t+1 SET COLOR white PLOT l+4,b-3; r-3,b-3; r-3,t+4 PLOT l,b-1; l,t; r-1,t SET COLOR c BOX AREA l+5,r-5,b-5,t+5 END SUB SUB HRule(l,r,b,h,c) LET t= b-h SET COLOR c BOX AREA l,r,b,t SET COLOR black PLOT l,b; r,b SET COLOR white PLOT l,t; r,t END SUB SUB Panel(l,r,b,t,c) SET COLOR 0 BOX AREA l,r,b,t SET COLOR white PLOT l+1,b; r,b; r,t+1 PLOT l+3,b-3; l+3,t+3; r-3,t+3 SET COLOR black PLOT l+4,b-3; r-3,b-3; r-3,t+4 PLOT l,b-1; l,t; r-1,t SET COLOR c BOX AREA l+5,r-5,b-5,t+5 END SUB ! ---- Color Subs ----- SUB Palette ! LET b0= 0 ! LET b1= 0.30 ! LET b2= 0.40 ! LET b3= 0.60 ! LET b4= 0.70 ! LET b5= 1.00 LET b0= 0 LET b1= 0.20 LET b2= 0.40 LET b3= 0.60 LET b4= 0.80 LET b5= 1.00 IF colorscheme=0 then SET COLOR MIX(0) b0,.2,.4 ! Back ELSE SET COLOR MIX(0) b4,b4,b4 ! Back SET COLOR MIX(0) .7,.7,.7 ! Back END IF SET BACK 0 SET COLOR 0 CLEAR SET COLOR MIX( 1) b0,b0,b0 ! black SET COLOR MIX( 2) b1,b1,b1 ! dark gray SET COLOR MIX( 3) b2,b2,b2 ! dark mid SET COLOR MIX( 4) b3,b3,b3 ! lite mid SET COLOR MIX( 5) b4,b4,b4 ! lite gray SET COLOR MIX( 6) b5,b5,b5 ! white IF colorscheme=0 then SET COLOR MIX( 7) b5,b2,b0 ! red SET COLOR MIX( 8) b5,b5,b0 ! yellow SET COLOR MIX( 9) b1,b5,b0 ! green SET COLOR MIX(10) b0,b5,b5 ! cyan SET COLOR MIX(11) b2,b2,b5 ! blue SET COLOR MIX(12) b5,b1,b5 ! magenta SET COLOR MIX(13) b5,b3,b0 ! ELSE SET COLOR MIX( 7) b3,b1,b0 ! red SET COLOR MIX( 8) b4,b3,b0 ! yellow SET COLOR MIX( 9) b0,b2,b0 ! green SET COLOR MIX(10) b0,b3,b3 ! cyan SET COLOR MIX(11) b2,b0,b4 ! blue SET COLOR MIX(12) b3,b0,b3 ! magenta SET COLOR MIX(13) b5,b3,b0 ! magenta END IF FOR i= 1 to 13 SET COLOR i NEXT i LET black = 1 LET drkgry = 2 LET drkmid = 3 LET midgry = 3 LET litmid = 4 LET litgry = 5 LET white = 6 LET red = 7 LET yellow = 8 LET green = 9 LET cyan = 10 LET blue = 11 LET magenta= 12 IF colorscheme=0 then LET planeclr= black LET gridclr = drkgry LET rimclr = drkmid LET axisclr = litgry LET axislabelclr= white LET titleclr = litgry LET rightsclr = litmif LET numberlineclr= litgry LET slotdrkclr= black LET slotlgtclr= litmid ELSE LET planeclr= white LET gridclr = litgry LET rimclr = drkmid LET axisclr = drkgry LET axislabelclr= black LET titleclr= drkgry LET rightsclr= drkgry LET numberlineclr= drkgry LET slotdrkclr= drkgry LET slotlgtclr= white END IF END SUB SUB PaletteTest ASK PIXELS xpix,ypix LET xmax= xpix-1 LET ymax= ypix-1 FOR i= 1 to 12 SET COLOR i LET x= workLft + 100 + i*40 BOX AREA x,x+19,workBas,workTop NEXT i GET POINT: mx,my DATA 0,.35,.40,.54,.67,.80,1 END SUB END MODULE ! --- external support libraries --- MODULE Help DECLARE PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white DECLARE PUBLIC red,yellow,green,cyan,blue,magenta,colorscheme DECLARE PUBLIC planeclr,gridclr,rimclr,axisclr,axislabelclr,titleclr DECLARE PUBLIC workLft,workRgt,workBas,workTop,workMidx ! work area DECLARE PUBLIC M68kFlag DECLARE PUBLIC toolLft,toolRgt,toolBas,toolTop,toolhdr SUB InfoPage(Info$()) LET iLft= workLft LET iRgt= workRgt-1 LET iBas= workBas-2 LET iTop= workTop SET COLOR white BOX AREA iLft,iRgt,iBas,iTop CALL CopyRight(workLft+20,workbas-3,2) LET marg1 = iLft+30 LET marg2 = marg1+24 LET txtLft= marg1 LET txtRgt= iRgt-30 LET Basln = iTop+50 LET lnspc = 15 LET hlfspc= 8 LET clr = black SET COLOR clr CALL SetTextFont(1,12,"bold") LET linecount= ubound(Info$) FOR i= 1 to linecount LET txt$ = Info$(i) LET first$= txt$(1:1) IF first$= "x" or first$= "y" then LET txtLft= marg2 CALL SuperSubScriptLJ(txtLft,Basln,txt$,clr) LET Basln = Basln+lnspc ELSE IF first$= "-" then LET txtLft= marg2 LET txt$(1:1)= "" ELSE LET txtLft= marg1 END IF CALL Paragraph(txtLft,txtRgt,Basln,lnspc,txt$) END IF LET Basln= Basln+hlfspc NEXT i LET midpage= int((iLft+iRgt)/2) CALL SetTextFont(1,9,"bold") LET cbtnLft= midpage-35 LET cbtnRgt= midpage+35 LET cbtnBas= iBas-10 LET cbtnTop= cbtnBas-17 CALL DrawButton(cbtnLft,cbtnRgt,cbtnBas,cbtnTop,5,"Continue") CALL MouseDown(mx,my,ms) IF mx>cbtnLft and mxcbtnTop and myWidth or Rgtpnt=endofpar LET line$ = trim$(para$(Lftpnt:Rgtpnt)) CALL PlotTextLJ(txtLft,Basln,line$,clr) LET Basln = Basln + lnspc LET Lftpnt= min(Rgtpnt+1,endofpar) LOOP until Lftpnt=endofpar END SUB END SUB END MODULE ! ---- graphing methods SUB ClipVert(Bas,Top,x1,y1,x2,y2) ! this handles vertical clipping for pixel values LOCAL xd,yd,xm LET yd= y2-y1 LET xd= x2-x1 LET m = xd/yd IF y1>Bas then ! Clip Bas LET x1= x2 + m*(Bas-y2) LET y1= Bas ELSE IF y1Bas then ! Clip Bas LET x2= x1 + m*(Bas-y1) LET y2= Bas ELSE IF y20 then LET lines= abs(round(fWid/xstp)) FOR i= 0 to lines LET n = fLft + i*xstp LET wx= wndx(n) PLOT wx,wTop+1; wx,wBas-1 NEXT i END IF IF ystp>0 then LET lines= abs(round(fHgt/ystp)) IF fHgt<0 then LET first= fTop else LET first= fBas FOR i= 0 to lines LET n = first + i*ystp LET wy= wndy(n) PLOT wLft+1,wy; wRgt-1,wy NEXT i END IF SET COLOR rimclr BOX LINES wLft,wRgt,wBas,wTop END SUB SUB ZeroAxes(wx0,wy0,wLft,wRgt,wBas,wTop,dir,aclr) IF wy0>=wTop and wy0<=wBas then SET COLOR aclr PLOT wLft,wy0; wRgt+3,wy0 DRAW arrow3 with rotate(0) * shift(wRgt+2,wy0) END IF IF wx0>=wLft and wx0<=wRgt then SET COLOR aclr IF dir=1 then PLOT wx0,wBas; wx0,wTop-3 DRAW arrow3 with rotate(-pi/2) * shift(wx0,wTop-2) ELSE PLOT wx0,wBas+3; wx0,wTop DRAW arrow3 with rotate(pi/2) * shift(wx0,wBas+2) END IF END IF END SUB SUB EdgesVrt(wAxis,wBas,wTop,fBas,fTop,first,stp1,stp2,nstp,dir) BOX CLEAR wAxis-35,wAxis-5,wBas+4,wTop-4 BOX CLEAR wAxis- 4,wAxis ,wBas ,wTop CALL VNumberLineTiks(wBas,wTop,wAxis,fBas,fTop,first,stp1,stp2,nstp,dir) CALL VNumberLineLabels(wBas,wTop,wAxis,fBas,fTop,first,stp1,stp2,nstp,dir) END SUB SUB EdgesVrtPi(wAxis,wBas,wTop,fBas,fTop,first,stp1,stp2,nstp,dir) BOX CLEAR wAxis-35,wAxis-5,wBas+4,wTop-4 BOX CLEAR wAxis- 4,wAxis ,wBas ,wTop CALL VNumberLineTiks(wBas,wTop,wAxis,fBas,fTop,first,stp1,stp2,nstp,dir) CALL VNumberLineLabelsPi(wBas,wTop,wAxis,fBas,fTop,first,stp1,stp2,nstp,dir) END SUB SUB EdgesHrz(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,dir) IF dir=1 then BOX CLEAR wLft,wRgt,wBas+1,wBas+4 BOX CLEAR wLft-15,wRgt+20,wBas+4,wBas+15 END IF CALL HNumberLineTiks(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,dir) CALL HNumberLineLabels(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,dir) END SUB SUB EdgesHrzPi(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,dir) BOX CLEAR wLft,wRgt,wBas+1,wBas+4 BOX CLEAR wLft-15,wRgt+20,wBas+4,wBas+15 CALL HNumberLineTiks(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,dir) CALL HNumberLineLabelsPi(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,dir) END SUB END MODULE MODULE MathGraphs DECLARE PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white DECLARE PUBLIC red,yellow,green,cyan,blue,magenta,colorscheme DECLARE PUBLIC planeclr,gridclr,rimclr,axisclr,axislabelclr,titleclr DECLARE PUBLIC numberlineclr,slotdrkclr,slotlgtclr,slideclr SUB VNumberLineTiks(wBas,wTop,wAxis,fBas,fTop,first,stp1,stp2,nstp,ndir) LOCAL fy,wHgt,fHgt,ticks,i,n,wy,s,n$,sl,form$,places DEF wndy(fy)= wBas - wHgt/fHgt*(fy-fBas) LET wHgt= wBas-wTop LET fHgt= fTop-fBas SET COLOR numberlineclr IF stp1>0 or stp2>0 then PLOT wAxis,wBas; wAxis,wTop ! Y boundary axis END IF IF stp1>0 then ! short ticks LET ticks= int(fHgt/stp1) FOR i= 0 to ticks LET n = first + i*stp1 LET wy= wndy(n) IF ndir=-1 then PLOT wAxis,wy; wAxis-2,wy ELSE IF ndir=1 then PLOT wAxis,wy; wAxis+2,wy END IF NEXT i END IF IF stp2>0 then ! long ticks LET ticks= int(fHgt/stp2) FOR i= 0 to ticks LET n = first + i*stp2 LET wy= wndy(n) IF ndir=-1 then PLOT wAxis,wy; wAxis-4,wy ELSE IF ndir=1 then PLOT wAxis,wy; wAxis+4,wy END IF NEXT i END IF END SUB SUB VNumberLineLabels(wBas,wTop,wAxis,fBas,fTop,first,stp1,stp2,nstp,ndir) LOCAL fx,wHgt,fHgt,ticks,i,n,wy,s,n$,sl,form$,places DEF wndy(fy)= wBas - wHgt/fHgt*(fy-fBas) LET wHgt= wBas-wTop LET fHgt= fTop-fBas IF ndir=-1 then IF stp1=0 and stp2=0 then LET rgtln= wAxis-3 ELSE LET rgtln= wAxis-6 END IF ELSE IF ndir=1 then IF stp1=0 and stp2=0 then LET rgtln= wAxis+7 ELSE LET rgtln= wAxis+11 END IF END IF SET COLOR numberlineclr IF stp1>0 or stp2>0 then PLOT wAxis,wBas; wAxis,wTop ! Y boundary axis END IF IF nstp>0 then ! labels IF int(nstp)= nstp then ! build format LET form$= "------#" ELSE LET places= abs(int(log10(nstp))) LET form$ = "--%." & repeat$("#",places) END IF CALL SetTextFont(1,9,"normal") LET ticks= abs(int(fHgt/nstp)) FOR i= 0 to ticks LET n = first + i*nstp LET n = round(n,7) LET wy= wndy(n) LET s = sgn(n) IF s=0 then LET n$= "0" !CALL SetTextFont(1,9,"bold") ELSE LET n$= trim$(using$(form$,n)) !CALL SetTextFont(1,9,"normal") END IF CALL PlotTextRJ(rgtln,wy+3,n$,numberlineclr) NEXT i END IF END SUB SUB VNumberLineLabelsPi(wBas,wTop,wAxis,fBas,fTop,first,stp1,stp2,nstp,ndir) LOCAL fx,wHgt,fHgt,ticks,i,n,wy,s,n$,sl,form$,places DEF pi$= "w" DEF wndy(fy)= wBas - wHgt/fHgt*(fy-fBas) LET wHgt= wBas-wTop LET fHgt= fTop-fBas IF ndir=-1 then IF stp1=0 and stp2=0 then LET rgtln= wAxis-3 ELSE LET rgtln= wAxis-6 END IF ELSE IF ndir=1 then IF stp1=0 and stp2=0 then LET rgtln= wAxis+7 ELSE LET rgtln= wAxis+11 END IF END IF SET COLOR numberlineclr IF stp1>0 or stp2>0 then PLOT wAxis,wBas; wAxis,wTop ! Y boundary axis END IF IF nstp>0 then ! labels IF int(nstp)= nstp then ! build format LET form$= "------#" ELSE LET places= abs(int(log10(nstp))) LET form$ = "--%." & repeat$("#",places) END IF CALL SetTextFont(1,9,"normal") LET ticks= abs(int(fHgt/nstp)) FOR i= 0 to ticks LET n = first + i*nstp LET n = round(n,5) LET wy = wndy(n) LET abn= abs(n) LET s = sgn(n) CALL SetTextFont(1,9,"normal") SELECT CASE abn CASE 0 LET n$= "0" !CALL SetTextFont(1,9,"bold") CASE 0.5 LET n$= pi$ & "/2" CASE 1 LET n$= pi$ CASE 1.5 LET n$= "3" & pi$ & "/2" CASE 2.5 LET n$= "5" & pi$ & "/2" CASE 3.5 LET n$= "7" & pi$ & "/2" CASE 2,3,4,5,6,7,8,9,10,11,12 LET n$= trim$(str$(abn)) & pi$ CASE else END SELECT CALL StringWidth(n$,sl) LET left= rgtln - sl LET p= pos(n$,pi$) LET l= len(n$) LET basln= wy+3 IF p=0 then CALL PlotTextRJ(rgtln,basln,n$,numberlineclr) ELSE IF p=1 then LET n$= n$(2:l) DRAW pi9 with shift(left,basln) CALL PlotTextRJ(rgtln,basln,n$,numberlineclr) ELSE IF p=l then LET n$= n$(1:l-1) CALL PlotTextLJ(left,basln,n$,numberlineclr) CALL StringWidth(n$,sw) DRAW pi9 with shift(left+sw,basln) ELSE LET Lft$= n$(1:p-1) LET Rgt$= n$(p+1:l) CALL PlotTextLJ(left,basln,Lft$,numberlineclr) CALL StringWidth(Lft$,sw) DRAW pi9 with shift(left+sw,basln) CALL PlotTextLJ(left+sw+8,basln,Rgt$,numberlineclr) END IF IF s=-1 then CALL PlotTextRJ(left-1,basln,"-",numberlineclr) NEXT i END IF END SUB SUB HNumberLineTiks(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,ndir) LOCAL wWid,fWid,ticks,i,n,wx DEF wndx(fx)= wLft + wWid/fWid*(fx-fLft) ! function to window LET wWid= wRgt-wLft LET fWid= fRgt-fLft SET COLOR numberlineclr IF stp1<>0 or stp2<>0 then PLOT wLft,wBas; wRgt,wBas ! axis line if ticks are on END IF IF stp1>0 then ! short ticks LET ticks= int(fWid/stp1) FOR i= 0 to ticks LET n = first + i*stp1 LET wx= wndx(n) IF ndir=-1 then PLOT wx,wBas; wx,wBas-2 ELSE IF ndir=1 then PLOT wx,wBas; wx,wBas+2 END IF NEXT i END IF IF stp2>0 then ! long ticks LET ticks= int(fWid/stp2) FOR i= 0 to ticks LET n = first + i*stp2 LET wx= wndx(n) IF ndir=-1 then PLOT wx,wBas; wx,wBas-4 ELSE IF ndir=1 then PLOT wx,wBas; wx,wBas+4 END IF NEXT i END IF END SUB SUB HNumberLineLabels(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,ndir) LOCAL wWid,fWid,places,form$,ticks,i,n,wx,s,n$,sl,left,basln DEF wndx(fx)= wLft + wWid/fWid*(fx-fLft) ! function to window LET wWid= wRgt-wLft LET fWid= fRgt-fLft IF ndir=-1 then IF stp1=0 and stp2=0 then LET basln= wBas-5 ELSE LET basln= wBas-7 END IF ELSE IF ndir=1 then IF stp1=0 and stp2=0 then LET basln= wBas+11 ELSE LET basln= wBas+14 END IF END IF SET COLOR numberlineclr IF stp1<>0 or stp2<>0 then PLOT wLft,wBas; wRgt,wBas ! axis line if ticks are on END IF IF nstp>0 then ! labels IF int(nstp)= nstp then ! build format LET form$ = "----#" ELSE LET places= abs(int(log10(nstp))) LET form$ = "--%." & repeat$("#",places) !LET form$ = "-%.#" END IF CALL SetTextFont(1,9,"normal") LET ticks= round(fWid/nstp) FOR i= 0 to ticks LET n = first + i*nstp LET n = round(n,5) LET wx= wndx(n) LET s = sgn(n) IF s=0 then LET n$= "0" !CALL SetTextFont(1,9,"bold") ELSE LET n$= trim$(using$(form$,abs(n))) !CALL SetTextFont(1,9,"normal") END IF CALL StringWidth(n$,sl) LET left= round(wx - sl/2) + 1 CALL PlotTextLJ(left,basln,n$,numberlineclr) IF s=-1 then CALL PlotTextRJ(left-1,basln,"-",numberlineclr) NEXT i END IF END SUB SUB HNumberLineLabelsPi(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,ndir) LOCAL wWid,fWid,places,form$,ticks,i,n,wx,abn,s,n$,sl,lft$,rgt$,left,basln DEF pi$= "w" DEF wndx(fx)= wLft + wWid/fWid*(fx-fLft) ! function to window LET wWid= wRgt-wLft LET fWid= fRgt-fLft IF ndir=-1 then IF stp1=0 and stp2=0 then LET basln= wBas-3 ELSE LET basln= wBas-7 END IF ELSE IF ndir=1 then IF stp1=0 and stp2=0 then LET basln= wBas+10 ELSE LET basln= wBas+14 END IF END IF SET COLOR numberlineclr IF stp1<>0 or stp2<>0 then PLOT wLft,wBas; wRgt,wBas ! axis line if ticks are on END IF IF nstp>0 then ! labels IF int(nstp)= nstp then ! build format LET form$ = "----#" ELSE LET places= abs(int(log10(nstp))) LET form$ = "--%." & repeat$("#",places) END IF CALL SetTextFont(1,9,"normal") LET ticks= round(fWid/nstp) FOR n= fLft to fRgt step nstp LET n = round(n,5) LET wx = wndx(n) LET abn= abs(n) LET s = sgn(n) CALL SetTextFont(1,9,"normal") SELECT CASE abn CASE 0 LET n$= "0" !CALL SetTextFont(1,9,"bold") CASE 0.5 LET n$= pi$ & "/2" CASE 1 LET n$= pi$ CASE 1.5 LET n$= "3" & pi$ & "/2" CASE 2.5 LET n$= "5" & pi$ & "/2" CASE 3.5 LET n$= "7" & pi$ & "/2" CASE else LET n$= trim$(str$(abn)) & pi$ !CASE else END SELECT CALL StringWidth(n$,sl) LET left= wx - sl/2 + 1 LET p= pos(n$,pi$) LET l= len(n$) IF p=0 then CALL PlotTextLJ(left,basln,n$,numberlineclr) ELSE IF p=1 then LET n$= n$(2:l) DRAW pi9 with shift(left,basln) CALL PlotTextLJ(left+8,basln,n$,numberlineclr) ELSE IF p=l then LET n$= n$(1:l-1) CALL PlotTextLJ(left,basln,n$,numberlineclr) CALL StringWidth(n$,sw) DRAW pi9 with shift(left+sw,basln) ELSE LET Lft$= n$(1:p-1) LET Rgt$= n$(p+1:l) CALL PlotTextLJ(left,basln,Lft$,numberlineclr) CALL StringWidth(Lft$,sw) DRAW pi9 with shift(left+sw,basln) CALL PlotTextLJ(left+sw+8,basln,Rgt$,numberlineclr) END IF IF s=-1 then CALL PlotTextRJ(left-1,basln,"-",numberlineclr) NEXT n END IF END SUB END MODULE ! ----- library slider subs MODULE v1slider PUBLIC v1axis,v1wLft,v1wRgt,v1wBas,v1wTop,v1wHgt,v1sBas,v1sTop PUBLIC v1fBas,v1fTop,v1First,v1STik,v1LTik,v1Label,v1fHgt,v1yf,v1y2,v1y4,v1yl PUBLIC v1fRatio,v1wRatio,v1name$,v1m,v1form$,v1clr,v1slot$ DEF v1fncy(wy)= v1fBas + v1fRatio*(v1wBas-wy) ! window to function DEF v1wndy(fy)= v1wBas + v1wRatio*(fy-v1fBas) ! function to window SUB v1SliderVariables CALL vWnd(v1axis,v1wLft,v1wRgt,v1wBas,v1wTop,v1wHgt,v1sBas,v1sTop) CALL vFnc(v1fBas,v1fTop,v1fHgt) CALL vRatios(v1fHgt,v1wHgt,v1fRatio,v1wRatio) END SUB SUB v1DrawSlider(n) BOX CLEAR v1wLft,v1wRgt,v1wBas+15,v1wTop-20 CALL SliderSlotV(v1wBas,v1wTop,v1axis) CALL SliderAxisVrt(v1wBas,v1wTop,v1axis,v1fBas,v1fTop,v1first,v1STik,v1LTik,v1Label) BOX KEEP v1axis,v1wRgt,v1sBas,v1sTop in v1slot$ CALL PlotVSliderName(v1axis,v1wBas,v1name$,v1clr) CALL v1Mark(n) END SUB SUB v1Mark(n) LET wy= v1wBas - v1wRatio*(n-v1fBas) BOX SHOW v1slot$ at v1axis,v1sBas CALL SliderKnobV(v1wRgt-5,wy) CALL PlotVSliderValue(v1axis,v1wTop-5,using$(v1form$,n*v1m),v1clr) END SUB END MODULE MODULE h1slider PUBLIC h1axis,h1wLft,h1wRgt,h1wBas,h1wTop,h1wWid,h1sLft,h1sRgt PUBLIC h1fLft,h1fRgt,h1fWid,h1First,h1STik,h1LTik,h1Label ! h1xf,h1x2,h1x4,h1xl PUBLIC h1fratio,h1wratio,h1name$,h1m,h1form$,h1clr,h1slot$ DEF h1fncx(wx)= h1fLft + h1fratio*(wx-h1wLft) ! window to function DEF h1wndx(fx)= h1wLft + h1wratio*(fx-h1fLft) ! function to window SUB h1SliderVariables CALL hWnd(h1axis,h1wLft,h1wRgt,h1wBas,h1wTop,h1wWid,h1sLft,h1sRgt) CALL hFnc(h1fLft,h1fRgt,h1fWid) CALL hRatios(h1fWid,h1wWid,h1fratio,h1wratio) END SUB SUB h1DrawSlider(n) BOX CLEAR h1wLft-20,h1wRgt+35,h1wBas,h1wTop CALL SliderSlotH(h1wLft,h1wRgt,h1axis) CALL SliderAxisHrz(h1wLft,h1wRgt,h1axis,h1fLft,h1fRgt,h1First,h1STik,h1LTik,h1Label) BOX KEEP h1sLft,h1sRgt,h1wBas,h1axis in h1slot$ CALL PlotSliderName(h1wLft,h1wBas,h1name$,h1clr) CALL h1Mark(n) END SUB SUB h1Mark(n) LET wx= h1wLft + h1wratio*(n-h1fLft) BOX SHOW h1slot$ at h1sLft,h1wBas CALL SliderKnob(wx,h1wBas-5) CALL PlotSliderValue(h1wRgt,h1wBas,using$(h1form$,n*h1m),h1clr) END SUB END MODULE MODULE hSlider2 PUBLIC h2axis,h2wLft,h2wRgt,h2wBas,h2wTop,h2wWid,h2sLft,h2sRgt PUBLIC h2fLft,h2fRgt,h2First,h2STik,h2LTik,h2Label,h2fWid,h2xf,h2x2,h2x4,h2xl PUBLIC h2fratio,h2wratio,h2name$,h2m,h2form$,h2clr PUBLIC hslot2$ DEF h2Fncx(wx)= h2fLft + h2fratio*(wx-h2wLft) ! window to function DEF h2Wndx(fx)= h2wLft + h2wratio*(fx-h2fLft) ! function to window SUB hSlider2Variables CALL hWnd(h2axis,h2wLft,h2wRgt,h2wBas,h2wTop,h2wWid,h2sLft,h2sRgt) CALL hFnc(h2fLft,h2fRgt,h2fWid) CALL hRatios(h2fWid,h2wWid,h2fratio,h2wratio) END SUB SUB h2DrawSlider(n) BOX CLEAR h2wLft-20,h2wRgt+35,h2wBas,h2wTop CALL SliderSlotH(h2wLft,h2wRgt,h2axis) CALL SliderAxisHrz(h2wLft,h2wRgt,h2axis,h2fLft,h2fRgt,h2First,h2STik,h2LTik,h2Label) BOX KEEP h2sLft,h2sRgt,h2wBas,h2axis in hSlot2$ CALL PlotSliderName(h2wLft,h2wBas,h2name$,h2clr) CALL h2Mark(n) END SUB SUB h2Mark(n) LET wx= h2wLft + h2wratio*(n-h2fLft) BOX SHOW hSlot2$ at h2sLft,h2wBas CALL SliderKnob(wx,h2wBas-5) CALL PlotSliderValue(h2wRgt,h2wBas,using$(h2form$,n*h2m),h2clr) END SUB END MODULE MODULE hSlider3 PUBLIC h3axis,h3wLft,h3wRgt,h3wBas,h3wTop,h3wWid,h3sLft,h3sRgt PUBLIC h3fLft,h3fRgt,h3First,h3STik,h3LTik,h3Label,h3fWid,h3xf,h3x2,h3x4,h3xl PUBLIC h3fratio,h3wratio,h3name$,h3m,h3form$,h3clr PUBLIC hslot3$ DEF h3Fncx(wx)= h3fLft + h3fratio*(wx-h3wLft) ! window to function DEF h3Wndx(fx)= h3wLft + h3wratio*(fx-h3fLft) ! function to window SUB hSlider3Variables CALL hWnd(h3axis,h3wLft,h3wRgt,h3wBas,h3wTop,h3wWid,h3sLft,h3sRgt) CALL hFnc(h3fLft,h3fRgt,h3fWid) CALL hRatios(h3fWid,h3wWid,h3fratio,h3wratio) END SUB SUB h3DrawSlider(n) BOX CLEAR h3wLft-20,h3wRgt+35,h3wBas,h3wTop CALL SliderSlotH(h3wLft,h3wRgt,h3axis) CALL SliderAxisHrz(h3wLft,h3wRgt,h3axis,h3fLft,h3fRgt,h3First,h3STik,h3LTik,h3Label) BOX KEEP h3sLft,h3sRgt,h3wBas,h3axis in hSlot3$ CALL PlotSliderName(h3wLft,h3wBas,h3name$,h3clr) CALL h3Mark(n) END SUB SUB h3Mark(n) LET wx= h3wLft + h3wratio*(n-h3fLft) BOX SHOW hSlot3$ at h3sLft,h3wBas CALL SliderKnob(wx,h3wBas-5) CALL PlotSliderValue(h3wRgt,h3wBas,using$(h3form$,n*h3m),h3clr) END SUB END MODULE MODULE hSlider4 PUBLIC h4axis,h4wLft,h4wRgt,h4wBas,h4wTop,h4wWid,h4sLft,h4sRgt PUBLIC h4fLft,h4fRgt,h4First,h4STik,h4LTik,h4Label,h4fWid,h4xf,h4x2,h4x4,h4xl PUBLIC h4fratio,h4wratio,h4name$,h4m,h4form$,h4clr PUBLIC hSlot4$ DEF h4Fncx(wx)= h4fLft + h4fratio*(wx-h4wLft) ! window to function DEF h4Wndx(fx)= h4wLft + h4wratio*(fx-h4fLft) ! function to window SUB hSlider4Variables CALL hWnd(h4axis,h4wLft,h4wRgt,h4wBas,h4wTop,h4wWid,h4sLft,h4sRgt) CALL hFnc(h4fLft,h4fRgt,h4fWid) CALL hRatios(h4fWid,h4wWid,h4fratio,h4wratio) END SUB SUB h4DrawSlider(n) BOX CLEAR h4wLft-20,h4wRgt+45,h4wBas,h4wTop CALL SliderSlotH(h4wLft,h4wRgt,h4axis) CALL SliderAxisHrz(h4wLft,h4wRgt,h4axis,h4fLft,h4fRgt,h4First,h4STik,h4LTik,h4Label) BOX KEEP h4sLft,h4sRgt,h4wBas,h4axis in hSlot4$ CALL PlotSliderName(h4wLft,h4wBas,h4name$,h4clr) CALL h4Mark(n) END SUB SUB h4Mark(n) LET wx= h4wLft + h4wratio*(n-h4fLft) BOX SHOW hSlot4$ at h4sLft,h4wBas CALL SliderKnob(wx,h4wBas-5) CALL PlotSliderValue(h4wRgt,h4wBas,using$(h4form$,n*h4m),h4clr) END SUB END MODULE MODULE hSlider5 PUBLIC h5axis,h5wLft,h5wRgt,h5wBas,h5wTop,h5wWid,h5sLft,h5sRgt PUBLIC h5fLft,h5fRgt,h5First,h5STik,h5LTik,h5Label,h5fWid,h5xf,h5x2,h5x5,h5xl PUBLIC h5fratio,h5wratio,h5name$,h5m,h5form$,h5clr PUBLIC hSlot5$ DEF h5Fncx(wx)= h5fLft + h5fratio*(wx-h5wLft) ! window to function DEF hwndx5(fx)= h5wLft + h5wratio*(fx-h5fLft) ! function to window SUB hSlider5Variables CALL hWnd(h5axis,h5wLft,h5wRgt,h5wBas,h5wTop,h5wWid,h5sLft,h5sRgt) CALL hFnc(h5fLft,h5fRgt,h5fWid) CALL hRatios(h5fWid,h5wWid,h5fratio,h5wratio) END SUB SUB h5DrawSlider(n) BOX CLEAR h5wLft-20,h5wRgt+45,h5wBas,h5wTop CALL SliderSlotH(h5wLft,h5wRgt,h5axis) CALL SliderAxisHrz(h5wLft,h5wRgt,h5axis,h5fLft,h5fRgt,h5First,h5STik,h5LTik,h5Label) BOX KEEP h5sLft,h5sRgt,h5wBas,h5axis in hSlot5$ CALL PlotSliderName(h5wLft,h5wBas,h5name$,h5clr) CALL h5Mark(n) END SUB SUB h5Mark(n) LET wx= h5wLft + h5wratio*(n-h5fLft) BOX SHOW hSlot5$ at h5sLft,h5wBas CALL SliderKnob(wx,h5wBas-5) CALL PlotSliderValue(h5wRgt,h5wBas,using$(h5form$,n*h5m),h5clr) END SUB END MODULE MODULE hSlider6 PUBLIC h6axis,h6wLft,h6wRgt,h6wBas,h6wTop,h6wWid,h6sLft,h6sRgt PUBLIC h6fLft,h6fRgt,h6First,h6STik,h6LTik,h6Label,h6fWid,h6xf,h6x2,h6x6,h6xl PUBLIC h6fratio,h6wratio,h6name$,h6m,h6form$,h6clr PUBLIC hSlot6$ DEF h6Fncx(wx)= h6fLft + h6fratio*(wx-h6wLft) ! window to function DEF hwndx6(fx)= h6wLft + h6wratio*(fx-h6fLft) ! function to window SUB hSlider6Variables CALL hWnd(h6axis,h6wLft,h6wRgt,h6wBas,h6wTop,h6wWid,h6sLft,h6sRgt) CALL hFnc(h6fLft,h6fRgt,h6fWid) CALL hRatios(h6fWid,h6wWid,h6fratio,h6wratio) END SUB SUB h6DrawSlider(n) BOX CLEAR h6wLft-20,h6wRgt+46,h6wBas,h6wTop CALL SliderSlotH(h6wLft,h6wRgt,h6axis) CALL SliderAxisHrz(h6wLft,h6wRgt,h6axis,h6fLft,h6fRgt,h6First,h6STik,h6LTik,h6Label) BOX KEEP h6sLft,h6sRgt,h6wBas,h6axis in hSlot6$ CALL PlotSliderName(h6wLft,h6wBas,h6name$,h6clr) CALL h6Mark(n) END SUB SUB h6Mark(n) LET wx= h6wLft + h6wratio*(n-h6fLft) BOX SHOW hSlot6$ at h6sLft,h6wBas CALL SliderKnob(wx,h6wBas-5) CALL PlotSliderValue(h6wRgt,h6wBas,using$(h6form$,n*h6m),h6clr) END SUB END MODULE MODULE SliderParts DECLARE PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white DECLARE PUBLIC red,yellow,green,cyan,blue,magenta,colorscheme DECLARE PUBLIC planeclr,gridclr,rimclr,axisclr,axislabelclr,titleclr DECLARE PUBLIC numberlineclr,slotdrkclr,slotlgtclr,slideclr ! ------------- SUB vWnd(axx,wLft,wRgt,wBas,wTop,wHgt,sBas,sTop) LET wHgt = wBas-wTop LET wLft = axx-13 LET wRgt = axx+13 LET sBas = wBas+5 LET sTop = wTop-5 END SUB SUB vFnc(fBas,fTop,fHgt) LET fHgt = fTop-fBas END SUB SUB vRatios(vfHgt,vwHgt,vfratio,vwratio) LET vfratio= vfHgt/vwHgt LET vwratio= vwHgt/vfHgt END SUB SUB PlotVSliderName(Mid,Bas,name$,clr) CALL SetTextFont(1,12,"bold") CALL PlotTextCJ(Mid,Bas+13,name$,clr) END SUB SUB PlotVSliderValue(Mid,Bas,value$,clr) CALL SetTextFont(1,12,"bold") BOX CLEAR mid-20,mid+20,Bas,Bas-13 CALL PlotTextCJ(Mid,Bas-3,trim$(value$),clr) END SUB SUB SliderslotV(wb,wt,axis) LET sx= axis+7 BOX CLEAR axis+1,axis+14,wb+4,wt-4 SET COLOR slotdrkclr BOX AREA sx,sx-1,wb+1,wt-1 SET COLOR slotlgtclr PLOT sx+1,wb+1; sx+1,wt-1 END SUB SUB PhaseSlotV(sLft,sRgt,syb,syt,sx,sliderV$) BOX CLEAR sLft,sRgt,syb,syt SET COLOR white PLOT sx+1,syb-4; sx+1,syt+4 BOX KEEP sLft,sRgt,syb,syt in sliderV$ END SUB SUB SliderAxisVrt(wBas,wTop,wAxis,fBas,fTop,first,stp1,stp2,nstp) CALL VNumberLineTiks(wBas,wTop,wAxis,fBas,fTop,first,stp1,stp2,nstp,-1) CALL VNumberLineLabels(wBas,wTop,wAxis,fBas,fTop,first,stp1,stp2,nstp,-1) END SUB SUB SliderKnobV(kx,ky) SET COLOR black BOX AREA kx-3,kx+4,ky+3,ky-2 BOX AREA kx-4,kx+5,ky+2,ky-1 SET COLOR litmid BOX AREA kx-3,kx+3,ky+2,ky-2 BOX AREA kx-4,kx+4,ky+1,ky-1 SET COLOR white PLOT kx-4,ky; kx-6,ky SET COLOR litgry PLOT kx-3,ky-2; kx+2,ky-2 PLOT kx-3,ky+2; kx+2,ky+2 PLOT kx-4,ky-1; kx-4,ky+1 SET COLOR white PLOT kx-2,ky; kx+2,ky END SUB ! ------------- SUB hWnd(axy,wLft,wRgt,wBas,wTop,wWid,sLft,sRgt) LET wWid = wRgt-wLft LET wTop = axy-13 LET wBas = axy+13 LET sLft = wLft-5 LET sRgt = wRgt+5 END SUB SUB hFnc(fLft,fRgt,fWid) LET fWid = fRgt-fLft END SUB SUB hRatios(hfWid,hwWid,hfratio,hwratio) LET hfratio= hfWid/hwWid LET hwratio= hwWid/hfWid END SUB SUB PlotSliderName(Lft,Bas,name$,clr) CALL SetTextFont(1,12,"bold") CALL PlotTextRJ(Lft-5,Bas-3,name$,clr) END SUB SUB PlotSliderValue(Rgt,Bas,value$,clr) CALL SetTextFont(1,12,"bold") BOX CLEAR Rgt+3,Rgt+50,Bas,Bas-13 CALL PlotTextLJ(Rgt+7,Bas-3,trim$(value$),clr) END SUB SUB SliderSlotH(wl,wr,axis) LET sy= axis+7 BOX CLEAR wl-4,wr+4,axis+14,axis+1 SET COLOR slotdrkclr BOX AREA wl-1,wr+1,sy,sy-1 SET COLOR slotlgtclr PLOT wl-1,sy+1; wr+1,sy+1 END SUB SUB SliderAxisHrz(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp) CALL HNumberLineTiks(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,-1) CALL HNumberLineLabels(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,-1) END SUB SUB SliderAxisHrzPi(wLft,wRgt,axy,fLft,fRgt,first,stp1,stp2,nstp) LOCAL wWid,fWid,n,n$,left,sl,places,form$ DEF pi$= "w" DEF fncx(wx)= fLft + fWid*(wx-wLft)/wWid ! win to func DEF wndx(fx)= round(wLft + wWid*(fx-fLft)/fWid) ! func to win LET wWid= wRgt-wLft LET fWid= fRgt-fLft CALL HNumberLineTiks(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,-1) CALL HNumberLineLabelsPi(wLft,wRgt,wBas,fLft,fRgt,first,stp1,stp2,nstp,-1) END SUB SUB SliderKnob(kx,ky) IF colorscheme=1 then SET COLOR black BOX AREA kx-2,kx+3,ky+4,ky-3 BOX AREA kx-1,kx+2,ky+5,ky-3 SET COLOR drkmid BOX AREA kx-2,kx+2,ky+2,ky-3 BOX AREA kx-1,kx+1,ky+4,ky-4 SET COLOR litgry PLOT kx-2,ky-3; kx-2,ky+2 PLOT kx+2,ky-3; kx+2,ky+2 PLOT kx-1,ky-4; kx+1,ky-4 SET COLOR black PLOT kx,ky-4; kx,ky-6 SET COLOR white PLOT kx,ky+3; kx,ky-2 ELSE SET COLOR black BOX AREA kx-2,kx+3,ky+4,ky-3 BOX AREA kx-1,kx+2,ky+5,ky-4 SET COLOR litmid BOX AREA kx-2,kx+2,ky+2,ky-3 BOX AREA kx-1,kx+1,ky+4,ky-4 SET COLOR litgry PLOT kx-2,ky-3; kx-2,ky+2 PLOT kx+2,ky-3; kx+2,ky+2 PLOT kx-1,ky-4; kx+1,ky-4 SET COLOR white PLOT kx,ky-4; kx,ky-6 PLOT kx,ky+3; kx,ky-2 END IF END SUB ! SUB hLine(name$,axy,wLft,wRgt,fLft,fRgt,xf,x2,x4,xl,pclr,slot$) ! CALL ClearSlider(wLft,wRgt,axy+15,axy-15) ! CALL SliderSlotH(wLft-3,wRgt+3,axy) ! CALL SliderAxisHrz(wLft,wRgt,axy,fLft,fRgt,xf,x2,x4,xl) ! CALL SetTextFont(1,12,"bold") ! CALL PlotTextRJ(wLft-5,axy+9,name$,pclr) ! END SUB ! ! SUB hLinePi(hname$,axy,wLft,wRgt,fLft,fRgt,xf,x2,x4,xl,pclr,slot$) ! CALL ClearSlider(wLft,wRgt,axy+15,axy-15) ! CALL SliderSlotH(wLft-3,wRgt+3,axy) ! CALL SliderAxisHrzPi(wLft,wRgt,axy,fLft,fRgt,xf,x2,x4,xl) ! CALL SetTextFont(1,12,"bold") ! CALL PlotTextRJ(wLft-5,axy+9,name$,pclr) ! END SUB ! SUB hMark(n,m,wLft,wRgt,wBas,fLft,ratio,form$,slot$,clr) ! LET wx= wLft + ratio*(n-fLft) ! BOX SHOW slot$ at wLft-3,wBas ! CALL SliderKnob(wx,wBas-5) ! BOX CLEAR wRgt+3,wRgt+50,wBas,wBas-12 ! CALL SetTextFont(1,12,"bold") ! CALL PlotTextLJ(wRgt+7,wBas-4,trim$(using$(form$,n*m)),clr) ! END SUB ! SUB ClearSlider(wLft,wRgt,wBas,wTop) ! BOX CLEAR wLft-20,wRgt+35,wBas,wTop ! END SUB ! PICTURE KnobH(clr) ! SET COLOR drkgry ! PLOT -2,-2; -2,3 ! PLOT -1,-3; -1,4 ! PLOT 0,-5; 0,4 ! PLOT 1,-3; 1,4 ! PLOT 2,-2; 2,3 ! SET COLOR white ! PLOT 0,-5; 0,2 ! END PICTURE ! PICTURE PhaseMark(clr) ! SET COLOR clr ! PLOT -2,-2; -2,2 ! PLOT -1,-3; -1,3 ! PLOT 0,-5; 0,5 ! PLOT 1,-3; 1,3 ! PLOT 2,-2; 2,2 ! END PICTURE END MODULE MODULE TypeSetting DECLARE PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white DECLARE PUBLIC red,yellow,green,cyan,blue,magenta,colorscheme DECLARE PUBLIC planeclr,gridclr,rimclr,axisclr,axislabelclr,titleclr ! ---- type subs ---- SUB PlotTextLJ(tx,ty,t$,clr) DECLARE PUBLIC M68kFlag SET COLOR clr IF M68kflag=1 then PLOT TEXT, AT tx,ty: t$ ! 4.04 ELSE PLOT TEXT, AT tx,ty+1: t$ ! TB5 END IF END SUB SUB PlotTextCJ(midb,ty,t$,clr) CALL StringWidth(t$,sl) LET Lft= midb - int(sl/2) CALL PlotTextLJ(Lft,ty,t$,clr) END SUB SUB PlotTextRJ(Rgt,ty,t$,clr) CALL StringWidth(t$,sl) LET Lft= Rgt - sl CALL PlotTextLJ(Lft,ty,t$,clr) END SUB SUB DropTextLJ(tx,ty,t$,clr) CALL PlotTextLJ(tx+1,ty+1,t$,black) CALL PlotTextLJ(tx,ty,t$,clr) END SUB SUB DropTextCJ(midb,ty,t$,clr) CALL StringWidth(t$,sl) LET Lft= midb - int(sl/2) CALL DropTextLJ(Lft,ty,t$,clr) END SUB SUB DropTextRJ(Rgt,ty,t$,clr) CALL StringWidth(t$,sl) LET Lft= Rgt - sl CALL DropTextLJ(Lft,ty,t$,clr) END SUB SUB AlignEqual(ex,ey,eq$,ec) LET e = pos(eq$,"=") LET Lft$= eq$(1:e) CALL StringWidth(Lft$,sl) CALL PlotTextLJ(ex-sl,ey,eq$,ec) END SUB SUB AlignDot(dx,dy,n$,dc) LET d = pos(n$,".") LET Lft$= n$(1:d) CALL StringWidth(Lft$,sl) CALL PlotTextLJ(dx-sl,dy,n$,dc) END SUB ! SUB AlignChar(chx,ty,clr,txt$,char$) ! LET p = pos(txt$,char$) ! LET lft$= txt$(1:p) ! CALL StringWidth(lft$,sl) ! SET COLOR 10 ! PLOT TEXT, AT chx-sl+1,ty+1: txt$ ! SET COLOR clr ! PLOT TEXT, AT chx-sl,ty: txt$ ! END SUB ! SUB AlignDot(ec,ex,ey,eq$) ! LET e = pos(eq$,".") ! LET lft$= eq$(1:e) ! CALL StringWidth(lft$,sl) ! SET COLOR ec ! PLOT TEXT, AT ex-sl,ey: eq$ ! END SUB ! ! SUB AlignEqualMono(ec,ex,ey,eq$) ! LET e = pos(eq$,"=") ! LET lft$= eq$(1:e) ! LET rgt$= eq$(e+1:len(eq$)) ! CALL StringWidth(lft$,sl) ! SET COLOR 10 ! PLOT TEXT, AT ex-sl+1,ey+1: lft$ ! SET COLOR ec ! PLOT TEXT, AT ex-sl,ey: lft$ ! CALL MonoSpace(9,0,ec,ex,ey,rgt$) ! END SUB SUB MeasureSuperSub(in$,pix) LET out$= in$ LET l = len(out$) LET extra$= "" FOR i= 1 to l LET chr$= out$(i:i) IF chr$="^" or chr$="_" or chr$="[" or chr$="]" then LET extra$= extra$ & chr$ !LET out$(i:i)= "" END IF NEXT i CALL SetTextFont(1,12,"bold") CALL StringWidth(in$,sl) CALL StringWidth(extra$,el) LET pix= sl-el END SUB SUB SuperSubScriptLJ(sx,sy,super$,sclr) CALL SuperSubScript(sx,sy,super$,sclr) END SUB SUB SuperSubScriptRJ(sx,sy,super$,sclr) CALL MeasureSuperSub(super$,sl) LET Lft= sx - sl CALL SuperSubScript(Lft,sy,super$,sclr) END SUB SUB SuperSubScriptCJ(sx,sy,super$,sclr) CALL MeasureSuperSub(super$,sl) LET Lft= sx - int(sl/2) CALL SuperSubScript(Lft,sy,super$,sclr) END SUB SUB SuperSubScript(sx,sy,super$,sclr) LOCAL p,last,p0,p1,p2,ll,el,rl LOCAL Lft$,exp$,Rgt$ LET Lft$,exp$,Rgt$= "" LET p0 = pos(super$,"^") LET p1 = pos(super$,"_") LET last= len(super$) CALL SetTextFont(1,12,"bold") IF p0=0 and p1=0 then CALL PlotTextLJ(sx,sy,super$,sclr) ELSE IF p0=0 then LET p= p1 ELSE IF p1=0 then LET p= p0 ELSE LET p= min(p1,p0) END IF LET Lft$= super$(1:p-1) LET p2 = pos(super$,"]") IF p2=0 then EXIT SUB LET exp$= super$(p+2:p2-1) LET Rgt$= super$(p2+1:last) CALL StringWidth(Lft$,ll) CALL PlotTextLJ(sx,sy,Lft$,sclr) CALL SetTextFont(1,9,"bold") CALL StringWidth(exp$,el) IF p0=p then CALL PlotTextLJ(sx+ll,sy-5,exp$,sclr) ELSE IF p1=p then CALL PlotTextLJ(sx+ll,sy+3,exp$,sclr) END IF CALL SetTextFont(1,12,"bold") IF Rgt$<>"" then CALL SuperSubScriptLJ(sx+ll+el,sy,Rgt$,sclr) END IF END IF END SUB SUB CmplxStr(cmplx$,real,imag) ! Numeric to text LET x$= using$("-%.##",round(real,2)) LET y$= using$("%.##",abs(round(imag,2))) IF imag<0 then LET sign$= " - " else LET sign$= " + " LET cmplx$= "( " & x$ & sign$ & y$ & " i )" END SUB SUB CmplxText(Lft,Bas,rl,im,clr) LET rldot = Lft+35 LET imdot = rldot+50 LET ix = imdot+20 LET txtrl$= trim$(using$("--%.##",rl)) LET txtim$= trim$(using$("++%.##",im)) CALL PlotTextLJ(Lft,Bas,"(",clr) CALL AlignDot(rldot,Bas,txtrl$,clr) CALL AlignDot(imdot,Bas,txtim$,clr) CALL PlotTextLJ(ix,Bas,"i )",clr) END SUB END MODULE MODULE Omega SHARE omega(0:6,0:9) SHARE omegawid,omegahgt LET omegawid= 10 LET omegahgt= 6 MAT READ omega DATA 0,1,1,0,0,0,0,1,1,0 DATA 1,1,0,0,0,0,0,0,1,1 DATA 1,1,0,0,1,1,0,0,1,1 DATA 1,1,0,0,1,1,0,0,1,1 DATA 1,1,0,0,1,1,0,0,1,1 DATA 0,1,1,1,1,1,1,1,1,0 DATA 0,0,1,1,0,0,1,1,0,0 SUB SwapOmega(lft,bas,t$,c$,clr) LET l= len(t$) LET x= lft FOR i= 1 to l LET ch$= t$(i:i) IF ch$=c$ then CALL DrawOmega12(x,bas,clr) LET x= x+omegawid ELSE CALL PlotTextLJ(x,bas,ch$,clr) CALL StringWidth(ch$,sw) LET x= x+sw END IF NEXT i END SUB SUB DrawOmega12(lft,bas,clr) SET COLOR clr LET top= bas-omegahgt FOR row= 0 to 6 LET wy= top+row FOR col= 0 to 9 LET bit= omega(row,col) IF bit=1 then LET wx= lft+col PLOT wx,wy END IF NEXT col NEXT row END SUB END MODULE !MODULE phi ! SHARE phi(0:10,0:6) ! SHARE phiwid ! LET phiwid= 7 ! ! MAT READ phi ! DATA 0,0,0,1,0,0,0 ! DATA 0,0,0,1,0,0,0 ! DATA 0,1,1,1,1,1,0 ! DATA 1,1,0,1,0,1,1 ! DATA 1,1,0,1,0,1,1 ! DATA 1,1,0,1,0,1,1 ! DATA 1,1,0,1,0,1,1 ! DATA 1,1,0,1,0,1,1 ! DATA 0,1,1,1,1,1,0 ! DATA 0,0,0,1,0,0,0 ! DATA 0,0,0,1,0,0,0 ! ! SUB SwapPhi(lft,bas,t$,c$,clr) ! LET l= len(t$) ! LET x= lft ! FOR i= 1 to l ! LET ch$= t$(i:i) ! IF ch$=c$ then ! CALL DrawPhi12(x,bas,clr) ! LET x= x+phiwid ! ELSE ! CALL PlotTextLJ(x,bas,ch$,clr) ! CALL StringWidth(ch$,sw) ! LET x= x+sw ! END IF ! NEXT i ! END SUB ! ! SUB DrawPhi12(lft,bas,clr) ! SET COLOR clr ! LET top= bas-9 ! FOR row= 0 to 10 ! LET wy= top+row ! FOR col= 0 to 6 ! LET bit= phi(row,col) ! IF bit=1 then ! LET wx= lft+col ! PLOT wx,wy ! END IF ! NEXT col ! NEXT row ! END SUB !END MODULE MODULE phi SHARE phi(0:10,0:6) SHARE thetawid LET thetawid= 7 MAT READ phi DATA 0,0,0,1,0,0,0 DATA 0,0,0,1,0,0,0 DATA 0,1,1,1,1,1,0 DATA 1,1,0,1,0,1,1 DATA 1,1,0,1,0,1,1 DATA 1,1,0,1,0,1,1 DATA 1,1,0,1,0,1,1 DATA 1,1,0,1,0,1,1 DATA 0,1,1,1,1,1,0 DATA 0,0,0,1,0,0,0 DATA 0,0,0,1,0,0,0 SUB SwapPhi(lft,bas,t$,c$,clr) LET l= len(t$) LET x= lft FOR i= 1 to l LET ch$= t$(i:i) IF ch$=c$ then CALL DrawPhi12(x,bas,clr) LET x= x+thetawid ELSE CALL PlotTextLJ(x,bas,ch$,clr) CALL StringWidth(ch$,sw) LET x= x+sw END IF NEXT i END SUB SUB DrawPhi12(lft,bas,clr) SET COLOR clr LET top= bas-9 FOR row= 0 to 10 LET wy= top+row FOR col= 0 to 6 LET bit= phi(row,col) IF bit=1 then LET wx= lft+col PLOT wx,wy END IF NEXT col NEXT row END SUB END MODULE MODULE PiChar SHARE PiChar(0:7,0:9) SHARE piwid,pihgt LET piwid= 10 LET pihgt= 7 MAT READ PiChar DATA 0,0,0,0,0,0,0,1,1,0 DATA 0,1,1,1,1,1,1,1,0,0 DATA 1,1,1,1,0,0,1,1,0,0 DATA 0,0,1,1,0,0,1,1,0,0 DATA 0,0,1,1,0,0,1,1,0,0 DATA 0,0,1,1,0,0,1,1,0,0 DATA 0,0,1,1,0,0,1,1,0,1 DATA 0,1,1,0,0,0,0,1,1,0 SUB SwapPi(lft,bas,t$,c$,clr) LET l= len(t$) LET x= lft FOR i= 1 to l LET ch$= t$(i:i) IF ch$=c$ then CALL DrawPi12(x,bas,clr) LET x= x+piwid ELSE CALL PlotTextLJ(x,bas,ch$,clr) CALL StringWidth(ch$,sw) LET x= x+sw END IF NEXT i END SUB SUB DrawPi12(lft,bas,clr) SET COLOR clr LET top= bas-pihgt FOR row= 0 to 7 LET wy= top+row FOR col= 0 to 9 LET bit= PiChar(row,col) IF bit=1 then LET wx= lft+col PLOT wx,wy END IF NEXT col NEXT row END SUB END MODULE MODULE GraphParts DECLARE PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white DECLARE PUBLIC red,yellow,green,cyan,blue,magenta,colorscheme DECLARE PUBLIC planeclr,gridclr,rimclr,axisclr,axislabelclr,titleclr,rightsclr ! ---- visual parts PICTURE arrow2 PLOT 2,0; 0, 2; 0,-2; 2,0 PLOT 0,2; 0,-2 PLOT 1,1; 1,-1 END PICTURE PICTURE arrow3 PLOT 3, 0; 0,-3; 0,3; 3,0 PLOT 1,-2; 1, 2 PLOT 2,-1; 2, 1 END PICTURE PICTURE arrow4 PLOT -2,-2; -2,2; 0,0; -2,-2 PLOT -3,-3; -3,3; 0,0; -3,-3 PLOT -4,-4; -4,4; 0,0; -4,-4 END PICTURE PICTURE pi9 PLOT 0,-4; 1,-5; 5,-5; 6,-6 PLOT 1, 0; 2,-1; 2,-5 PLOT 4, 0; 5,-1; 5,-5 END PICTURE PICTURE Diamond PLOT -2, 0; 2,0 PLOT -1,-1; -1,1 PLOT -0,-2; -0,2 PLOT 1,-1; 1,1 END PICTURE PICTURE diamond5(clr) SET COLOR clr PLOT -2, 0; 2,0 PLOT -1,-1; -1,1 PLOT -0,-2; -0,2 PLOT 1,-1; 1,1 SET COLOR planeclr PLOT -3,0; 0,3; 3,0; 0,-3; -3,0 END PICTURE PICTURE diamond7(clr) SET COLOR clr PLOT -3, 0 PLOT -2,-1; -2,1 PLOT -1,-2; -1,2 PLOT 0,-3; 0,3 PLOT 1,-2; 1,2 PLOT 2,-1; 2,1 PLOT 3, 0 ! SET COLOR black ! PLOT -4,0; 0,4; 4,0; 0,-4; -4,0 END PICTURE PICTURE Root(rWid) LET Lft= -rWid PLOT Lft+1,-12; 0,-12 PLOT Lft ,-11; 0,-11 PLOT Lft+1,-12; Lft-5,0; Lft-7,-4 PLOT Lft+2,-12; Lft-4,0; Lft-6,-4 END PICTURE PICTURE IntegralSign(clr) SET COLOR clr PLOT 0, -9; 0, 2 PLOT 1, -9; 1, 2 PLOT 1,-10; 2,-10 PLOT -1, 3; 0, 3 END PICTURE PICTURE Summation(clr) SET COLOR clr PLOT 0, 2; 7, 2 PLOT 0, 2; 6, -4; 0,-10 PLOT 1, 2; 7, -4; 1,-10 PLOT 0,-10; 7,-10 END PICTURE END MODULE MODULE InterAction DECLARE PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white DECLARE PUBLIC red,yellow,green,cyan,blue,magenta,colorscheme DECLARE PUBLIC planeclr,gridclr,rimclr,axisclr,axislabelclr,titleclr SUB DrawButton(l,r,b,t,tBas,t$) SET COLOR white BOX LINES l,r-1,b-1,t SET COLOR black BOX LINES l+1,r,b,t+1 SET COLOR drkgry BOX AREA l+1,r-1,b-1,t+1 IF t$<>"" then LET midb= int((l+r)/2) + 1 CALL PlotTextCJ(midb,b-tBas,t$,white) END IF END SUB ! ---- Mouse Button Action ---- SUB ButtonDown(l,r,b,t) SET COLOR black PLOT l,b; l,t; r,t SET COLOR white PLOT l+1,b; r,b; r,t+1 END SUB SUB ButtonUp(l,r,b,t) SET COLOR white PLOT l,b; l,t; r,t SET COLOR 1 PLOT l+1,b; r,b; r,t+1 END SUB SUB MouseButtonUp(Lft,Rgt,Bas,Top,ms) CALL ButtonDown(Lft,Rgt,Bas,Top) DO GET MOUSE: mx,my,ms LOOP until ms=3 CALL ButtonUp(Lft,Rgt,Bas,Top) END SUB SUB MouseUp(mx,my,ms) DO GET MOUSE: mx,my,ms LOOP until ms=3 END SUB SUB MouseDown(mx,my,ms) DO GET MOUSE: mx,my,ms LOOP until ms=2 END SUB END MODULE MODULE Timer SHARE unitTicks SUB SetTimer LET ticks1= 0 LET t1 = time DO LET ticks1= ticks1+1 LOOP until time-t1>=1 LET ticks2= 0 LET t1 = time DO LET ticks2= ticks2+1 LOOP until time-t1>=1 ! LET ticks3= 0 ! LET t1 = time ! DO ! LET ticks3= ticks3+1 ! LOOP until time-t1>=1 LET unitTicks= (ticks1+ticks2)/2 END SUB SUB Delay(ticksn) LOCAL count,tick,killTime LET count= round(ticksn*unitTicks) FOR tick= 1 to count LET killTime= time-t1 LET killTime= time-t1 NEXT tick END SUB END MODULE ! --- End of Library --- ! *** VibrationAmplitude Program *** SUB VibrationAmplitude DECLARE PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white DECLARE PUBLIC red,yellow,green,cyan,blue,magenta,colorscheme DECLARE PUBLIC planeclr,gridclr,rimclr,axisclr,axislabelclr,titleclr,slideclr DECLARE PUBLIC workLft,workRgt,workBas,workTop,workMidx DECLARE PUBLIC qLft,qRgt,qBas,qTop DECLARE PUBLIC infLft,infRgt,infBas,infTop ! PUBLIC h1a,h2b,h1olda,h2oldb ! PUBLIC h3c,h4d,h3oldc,h4oldd ! PUBLIC h6j,h5k,h6oldj,h5oldk ! --- help screen array --- DIM info$(1:1) MAT READ info$ DATA "Information on vibration amplitude and phase responses" ! ---------- Utility functions --- DEF clamp(n,lo,hi)= min(max(n,lo),hi) DEF roundn(n,step)= round(n/step)*step DEF e= exp(1) ! ---- Functions ---- !x" + bx' + w_n^2 x = cos(wt). ! !The slider should control w_n , and the natural range of its values !would be the same as the range of values of w -- say 0 to 4. !This corresponds to letting c range from 0 to 16. Some goofy !things happen when c is small, and it's probably sensible to limit !w_n to the range between 1 and 4. ! ! We were going to change the complex number at the bottom. ! It should be labeled 1/p(iw) = W(iw), I think. ! It is: ! 1/((w_n^2 - w^2) + ibw). ! Re= A*cos(phi) ! Im= A*sin(phi) ! !I don't know how you will want to plot this complex number. !Its magnitude is the gain, which you have graphed as A. !The argument is the negative of the phase lag, which you have graphed as phi. !To be explicit, ! ! A = 1/sqrt{(w_n^2 - w^2)^2 + b^2 w^2} ! ! and ! ! phi = atan(bw/(w_n^2 - w^2). ! ! Here atan(x) signifies the angle between 0 and pi whose tangent is x. ! !I have repeated these formulas because !I am not sure the computations of A and phi are right. It seems !to me that the near resonance peak should move when you change b, !and as it is now it doesn't. ! !So the new complex number will always have negative imaginary part. !Correspondingly, I think we should turn the phase lag graph upside !down and graph -phi against w. ! !I would also like to see what the curve in the complex plane looks !like, that you get when you fix b and w_n and vary w. This corresponds !to the curves in the w,A plane and the w,phi plane that you already !draw. ! !We were going to switch to plotting the periodic behavior right from the start. !Here it is, in case I didn't convey this earlier: ! !x = A cos(wt - phi). ! !Then we can display the phase lag right off. Also, there's no need to !increment the values of t displayed along the bottom of this graph. !In fact, it would make sense to me to have the thing just continue !automatically, eliminate the "continue" button, and have the "start" !button replaced by "stop" while it's going. !I guess c = omega_n. This means k = c^2, so ! A = k/sqr((k-w*w)^2 + b*b*w*w) ! amplitude ! !> phi = angle(c*c-w*w, b*w) ! phase shift ! !is correct but the c*c could be written k. ! !> dxdt = vel ! position !> dvdt = -k*c*c*pos - b*vel + k*cos(w*t) ! spring velocity ! !should be ! ! dvdt = -k*pos - b*vel + k*cos(w*t) ! spring velocity ! !> ss = A*cos(w*t - phi) ! steady state ! DEF fa(w) = k/sqr((k-w*w)^2 + b*b*w*w) ! Amplitude DEF fPhi(w)= angle(k-w*w,b*w) ! Phase shift DEF fRe(A,phi) = A*cos(phi) ! Real DEF fIm(A,phi) = A*sin(phi) ! Imaginary DEF dxdt(pos,vel) = vel ! position DEF dvdt(pos,vel) = -k*pos - b*vel + k*cos(w*t) ! velocity DEF ss(t) = A*cos(w*t - phi) ! steady state SUB DrawPhi(phix,phiy,phic) SET COLOR 10 LET phix= phix+1 LET phiy= phiy+1 BOX CIRCLE phix,phix+7,phiy-3,phiy-7 BOX CIRCLE phix+1,phix+6,phiy-3,phiy-7 PLOT phix+3,phiy; phix+3,phiy-10 PLOT phix+4,phiy; phix+4,phiy-10 SET COLOR phic LET phix= phix-1 LET phiy= phiy-1 BOX CIRCLE phix,phix+7,phiy-3,phiy-7 BOX CIRCLE phix+1,phix+6,phiy-3,phiy-7 PLOT phix+3,phiy; phix+3,phiy-10 PLOT phix+4,phiy; phix+4,phiy-10 ! PLOT phix+2,phiy-10; phix+5,phiy-10 ! upper phi ! PLOT phix+2,phiy; phix+5,phiy END SUB LET dt= 1/16 SUB RungeKutta4(x,v) LET dx1= dxdt(x,v) LET dv1= dvdt(x,v) LET x1 = x + .5*dx1*dt LET v1 = v + .5*dv1*dt LET dx2= dxdt(x1,v1) LET dv2= dvdt(x1,v1) LET x2 = x + .5*dx2*dt LET v2 = v + .5*dv2*dt LET dx3= dxdt(x2,v2) LET dv3= dvdt(x2,v2) LET x3 = x + dx3*dt LET v3 = v + dv3*dt LET dx4= dxdt(x3,v3) LET dv4= dvdt(x3,v3) LET dv = (dv1 + 2*dv2 + 2*dv3 + dv4) / 6 LET dx = (dx1 + 2*dx2 + 2*dx3 + dx4) / 6 LET v = v + dt*dv LET x = x + dt*dx END SUB ! ---------- Graphing plane parameters and methods ---------- LET wsize = 160 LET fsize = 4 LET pisize = 176 LET whgt = 160 LET axisclr= 4 ! --- plane 1 data --- DECLARE PUBLIC w1Lft, w1Rgt, w1Bas, w1Top, w1Midx, w1Midy DECLARE PUBLIC w1fLft, w1fRgt, w1fBas, w1fTop, w1x0, w1y0 DECLARE PUBLIC w1Firstx, w1SxTik, w1LxTik, w1xLabel, w1xGridstep DECLARE PUBLIC w1Firsty, w1SyTik, w1LyTik, w1yLabel, w1yGridstep DECLARE PUBLIC w1xPiFlag, w1wWid, w1wHgt, w1fHgt, w1fWid LET w1Flag= 1 LET w1xPiFlag= 1 LET w1Lft= workLft+150 ! pixel bounds LET w1Rgt= w1Lft+400 LET w1Top= workTop+60 LET w1Bas= w1Top+whgt LET w1fLft= 0 ! function bounds LET w1fRgt= 8 LET w1fTop= 4 LET w1fBas= -4 LET w1Xax$= "t" ! axis labels LET w1Yax$= "x" LET w1xGridstep= 1 ! horizontal grid intervals LET w1yGridstep= 1 ! vertical grid intervals LET w1SxTik = 1 ! horizontal axis Tik marks LET w1LxTik = 2 LET w1xLabel= 2 LET w1Firstx= w1fLft LET w1SyTik = 0.5 ! vertical axis Tik marks LET w1LyTik = 1 LET w1yLabel= 1 LET w1Firsty= w1fBas ! --- Plane 1 methods --- DECLARE DEF w1fncx,w1fncy,w1wndx,w1wndy ! window/function transforms CALL Plane1Variables SUB Plane1Clear BOX CLEAR w1Lft-20,w1Rgt+20,workBas-5,w1Top-20 END SUB SUB Plane1Redraw ! CALL Plane1Init ! CALL Plane1Update ! CALL t1Init ! CALL t2Init ! ! CALL t5Set ! ! CALL h1DrawSlider(h1a) ! CALL h2DrawSlider(h2b) END SUB SUB Plane1Init CALL DrawPlane1(0,1,1) ! grid, axes, zeroaxes CALL SetTextFont(1,12,"bold") CALL PlotTextLJ(w1Rgt+8,w1y0+3,w1Xax$,axislabelclr) ! axis labels CALL PlotTextCJ(w1x0,w1Top-10,w1Yax$,posclr) BOX KEEP w1Lft-5,w1Rgt+5,w1Bas+5,w1Top-5 in w1gridLayer$ END SUB SUB Plane1Refresh BOX SHOW w1gridLayer$ at w1Lft-5,w1Bas+5 END SUB SUB Plane1Graph BOX SHOW w1graphLayer$ at w1Lft-5,w1Bas+5 END SUB ! ------------------- Plane 2 simulation ----------------------- ! --- plane 2 data --- DECLARE PUBLIC w2Lft,w2Rgt,w2Bas,w2Top,w2Midx,w2Midy DECLARE PUBLIC w2fLft,w2fRgt,w2fBas,w2fTop,w2x0,w2y0 DECLARE PUBLIC w2Firstx, w2SxTik, w2LxTik, w2xLabel, w2xGridstep DECLARE PUBLIC w2Firsty, w2SyTik, w2LyTik, w2yLabel, w2yGridstep DECLARE PUBLIC w2xPiFlag LET w2Flag= 1 LET w2Lft = worklft+25 ! pixel bounds LET w2Rgt = w2Lft+50 LET w2Top = w1Top - w1wHgt/4 !- 15 LET w2Bas = w1Bas + w1whgt + 35 LET w2fLft= 0 ! function bounds * pi LET w2fRgt= 40 LET w2fTop= 9 LET w2fBas= -4 LET w2xGridstep= .5 ! horizontal grid intervals LET w2yGridstep= 1 ! vertical grid intervals LET w2xAx$= "t" ! axis labels LET w2yAx$= "I" LET w2SxTik = 0 ! horizontal axis Tik marks LET w2LxTik = 0 LET w2xLabel= 0 LET w2Firstx= w2fLft LET w2xPiFlag= 0 LET w2SyTik = 0 ! vertical axis Tik marks LET w2LyTik = 0 LET w2yLabel= 0 LET w2Firsty= w2fBas ! --- plane 2 methods --- DECLARE DEF w2fncx, w2fncy, w2wndx, w2wndy ! window/function transforms CALL Plane2Variables SUB Plane2Init !CALL DrawPlane2(0,0,0) ! grid, axes, zeroaxes !CALL Grid1 SET COLOR black BOX AREA w2Lft,w2Rgt,w2Bas,w2Top CALL SetTextFont(1,12,"bold") ! CALL PlotTextLJ(w2Rgt+8,w2y0+3,w2xAx$,axislabelclr) ! axis labels ! CALL PlotTextCJ(w2x0,w2Top-10,w2yAx$,axislabelclr) BOX KEEP w2Lft-5,w2Rgt+5,w2Bas+5,w2Top-5 in w2gridLayer$ END SUB SUB Plane2Refresh BOX SHOW w2gridLayer$ at w2Lft-5,w2Bas+5 END SUB SUB Plane2Graph BOX SHOW w2graphLayer$ at w2Lft-5,w2Bas+5 END SUB SUB Grid1 LOCAL i,wx SET COLOR drkmid FOR i= 2 to 6 step 2 LET wx= w2wndx(i) PLOT wx,w2Top+1; wx,w2Bas-1 NEXT i END SUB ! ------------------------------------------ ! --- plane 3 data --- DECLARE PUBLIC w3Lft,w3Rgt,w3Bas,w3Top,w3Midx,w3Midy DECLARE PUBLIC w3fLft,w3fRgt,w3fBas,w3fTop,w3x0,w3y0 DECLARE PUBLIC w3Firstx, w3SxTik, w3LxTik, w3xLabel, w3xGridstep DECLARE PUBLIC w3Firsty, w3SyTik, w3LyTik, w3yLabel, w3yGridstep ! DECLARE PUBLIC w3yPiFlag LET w3Flag= 1 ! plane is turned on or off LET w3Lft = w1Rgt+70 ! pixel bounds LET w3Rgt = w3Lft+whgt/2 LET w3Top = w1Top LET w3Bas = w1Top+whgt/2 LET w3fLft= 0 ! function bounds LET w3fRgt= 4 LET w3fTop= 4 LET w3fBas= 0 LET w3xAx$= "w" ! axis labels LET w3yAx$= "A" LET w3xGridstep= 1 ! grid line intervals LET w3yGridstep= 1 LET w3SxTik = .5 ! axis Tik marks LET w3LxTik = 1 LET w3xLabel= 1 LET w3Firstx= w3fLft ! LET w3yPiFlag= 1 LET w3SyTik = .5 LET w3LyTik = 1 LET w3yLabel= 1 LET w3Firsty= w3fBas ! --- plane 3 methods --- DECLARE DEF w3fncx,w3fncy,w3wndx,w3wndy ! window/function transforms CALL Plane3Variables SUB Plane3Clear BOX CLEAR w3Lft-20,w3Rgt+20,workBas-5,w3Top-20 END SUB SUB Plane3Redraw ! CALL Plane3Init ! CALL Plane3Update ! CALL t3Init ! CALL t4Init ! ! CALL t5Set ! CALL h3DrawSlider(h3c) ! CALL h4DrawSlider(h4d) END SUB SUB Plane3Init CALL DrawPlane3(0,1,-1,1) ! grid, axes, zeroaxes CALL SetTextFont(1,12,"bold") !CALL PlotTextLJ(w3Rgt+8,w3y0+3,w3xAx$,axislabelclr) ! axis labels CALL SwapOmega(w3Rgt+8,w3y0+3,w3xAx$,"w",white) CALL PlotTextCJ(w3x0,w3Top-10,w3yAx$,ampclr) BOX KEEP w3Lft-5,w3Rgt+5,w3Bas+5,w3Top-5 in w3gridLayer$ BOX KEEP w3Lft-5,w3Rgt+5,w3Bas+5,w3Top-5 in w3graphLayer$ END SUB SUB Plane3Refresh BOX SHOW w3gridLayer$ at w3Lft-5,w3Bas+5 END SUB SUB Plane3Graph BOX SHOW w3graphLayer$ at w3Lft-5,w3Bas+5 END SUB ! --- plane 4 data --- DECLARE PUBLIC w4Lft,w4Rgt,w4Bas,w4Top,w4Midx,w4Midy,w4wwid DECLARE PUBLIC w4fLft,w4fRgt,w4fBas,w4fTop,w4x0,w4y0 DECLARE PUBLIC w4Firstx, w4SxTik, w4LxTik, w4xLabel, w4xGridstep DECLARE PUBLIC w4Firsty, w4SyTik, w4LyTik, w4yLabel, w4yGridstep DECLARE PUBLIC w4yPiFlag LET w4Flag= 0 ! plane is turned on or off LET w4Lft = w3Lft ! pixel bounds LET w4Rgt = w4Lft+whgt/2 LET w4Top = w1Bas+20 LET w4Bas = w4Top+whgt/2 LET w4fLft= 0 ! function bounds LET w4fRgt= 4 LET w4fTop= 0 LET w4fBas= -1 LET w4m = 1 LET w4xAx$= "w" ! axis labels LET w4yAx$= "phi" LET w4xGridstep= 1 ! grid line intervals LET w4yGridstep= 1 LET w4SxTik = 0 ! axis Tik marks LET w4LxTik = 1 LET w4xLabel= 1 LET w4Firstx= w4fLft LET phi = 1 LET w4SyTik = 0 LET w4LyTik = 0.5 LET w4yLabel = 0.5 LET w4Firsty = w4fBas LET w4yPiFlag= 1 ! --- plane 4 methods --- DECLARE DEF w4fncx,w4fncy,w4wndx,w4wndy ! window/function transforms CALL Plane4Variables SUB Plane4Clear BOX CLEAR w4Lft-20,w4Rgt+20,workBas-5,w4Top-20 END SUB SUB Plane4Refresh BOX SHOW w4gridLayer$ at w4Lft-5,w4Bas+5 END SUB SUB Plane4Graph BOX SHOW w4graphLayer$ at w4Lft-5,w4Bas+5 END SUB SUB Plane4Init CALL DrawPlane4(0,-1,-1,1) ! grid, axes, zeroaxes CALL SetTextFont(1,12,"bold") ! CALL PlotTextLJ(w4Rgt+8,w4y0+3,w4xAx$,axislabelclr) ! axis labels ! CALL PlotTextCJ(w4x0,w4Top-10,w4yAx$,phiclr) CALL SwapPhi(w4x0-10,w4Bas+15,"-p","p",phiclr) CALL SwapOmega(w4Rgt+9,w4y0+3,"w","w",white) BOX KEEP w4Lft-5,w4Rgt+5,w4Bas+5,w4Top-5 in w4gridLayer$ END SUB ! --- plane 5 data --- DECLARE PUBLIC w5Lft,w5Rgt,w5Bas,w5Top,w5Midx,w5Midy,w5wwid DECLARE PUBLIC w5fLft,w5fRgt,w5fBas,w5fTop,w5x0,w5y0 DECLARE PUBLIC w5Firstx, w5SxTik, w5LxTik, w5xLabel, w5xGridstep DECLARE PUBLIC w5Firsty, w5SyTik, w5LyTik, w5yLabel, w5yGridstep LET w5Flag= 0 ! plane is turned on or off ! LET w5Lft = w4Rgt-200 ! pixel bounds ! LET w5Rgt = w5Lft+200 ! LET w5Top = w4Bas+ 55 ! LET w5Bas = w5Top+ 80 ! LET w5fLft= -15 ! function bounds ! LET w5fRgt= 25 ! LET w5fTop= 10 ! LET w5fBas= 0 LET w5Lft = w4Lft-w4wWid ! pixel bounds LET w5Rgt = w4Rgt LET w5Top = w4Bas+ 55 LET w5Bas = w5Top+ 80 LET w5fLft= -4 ! function bounds LET w5fRgt= 4 LET w5fTop= 0 LET w5fBas= -4 LET w5xAx$= "Re" ! axis labels LET w5yAx$= "Im" LET w5xGridstep= 1 ! grid line intervals LET w5yGridstep= 1 LET w5SxTik = 0 ! axis Tik marks LET w5LxTik = 1 LET w5xLabel= 1 LET w5Firstx= w5fLft LET b= 1 LET w5SyTik = 0 LET w5LyTik = 1 LET w5yLabel= 1 LET w5Firsty= w5fBas ! --- plane 5 methods --- DECLARE DEF w5fncx,w5fncy,w5wndx,w5wndy ! window/function transforms CALL Plane5Variables SUB Plane5Clear BOX CLEAR w5Lft-20,w5Rgt+20,workBas-5,w5Top-20 END SUB SUB Plane5Refresh BOX SHOW w5gridLayer$ at w5Lft-5,w5Bas+5 END SUB SUB Plane5Graph BOX SHOW w5graphLayer$ at w5Lft-5,w5Bas+5 END SUB SUB Plane5Init CALL DrawPlane5(0,1,1) ! grid, axes, zeroaxes CALL SetTextFont(1,12,"bold") CALL PlotTextLJ(w5Rgt+8,w5y0+3,w5xAx$,axislabelclr) ! axis labels CALL PlotTextCJ(w5x0,w5Top-10,w5yAx$,axislabelclr) BOX KEEP w5Lft-5,w5Rgt+5,w5Bas+5,w5Top-5 in w5gridLayer$ END SUB ! ---------- Slider parameters and methods ---------- ! ----------- horizontal sliders ------------ ! --- horizontal slider 1 --- DECLARE DEF h1Fncx ! window/function transforms DECLARE PUBLIC h1axis,h1wLft,h1wRgt,h1wBas,h1wTop,h1sLft,h1sRgt DECLARE PUBLIC h1fLft,h1fRgt,h1First,h1STik,h1LTik,h1Label DECLARE PUBLIC h1name$,h1m,h1form$,h1clr LET h1clr = white LET h1name$= "b" LET h1form$= "-%.##" LET h1m = 1 LET h1axis = w1Bas + 95 LET h1wLft = w1Lft LET h1wRgt = h1wlft + 200 LET h1fLft = 0.5 LET h1fRgt = 1.5 LET h1STik = 0.1 ! short tick marks LET h1LTik = 0.50 ! long tick marks LET h1Label= 0.50 ! labels LET h1First= 0.5 ! first tick mark CALL h1SliderVariables ! --- Slider 2 --- DECLARE DEF h2Fncx,h2Wndx ! window/function transforms DECLARE PUBLIC h2axis,h2wLft,h2wRgt,h2wBas,h2wTop,h2sLft,h2sRgt DECLARE PUBLIC h2fLft,h2fRgt,h2First,h2STik,h2LTik,h2Label DECLARE PUBLIC h2name$,h2m,h2form$,h2clr LET h2clr = white LET h2name$ = "" LET h2form$ = "--%.##" LET h2m = 1 LET h2axis = w3Bas + 50 LET h2wLft = w3Lft LET h2wRgt = w3Rgt LET h2fLft = 0 LET h2fRgt = 4 LET h2STik = 0.5 LET h2LTik = 1 LET h2Label= 1 LET h2First= h2fLft CALL HSlider2Variables ! --- slider 3 --- DECLARE DEF h3Fncx ! window/function transforms DECLARE PUBLIC h3axis,h3wLft,h3wRgt,h3wBas,h3wTop,h3sLft,h3sRgt DECLARE PUBLIC h3fLft,h3fRgt,h3First,h3STik,h3LTik,h3Label DECLARE PUBLIC h3name$,h3m,h3form$,h3clr LET h3clr = white LET h3name$ = "" LET h3form$ = "-%.##" LET h3m = 1 LET h3axis = h1axis+ 80 LET h3wLft = h1wLft LET h3wRgt = h3wLft+200 LET h3fLft = 1 LET h3fRgt = 4 LET h3STik = 0 LET h3LTik = 0.5 LET h3Label= 1 LET h3First= h3fLft CALL HSlider3Variables ! --- slider 4 --- DECLARE DEF h4Fncx ! window/function transforms DECLARE PUBLIC h4axis,h4wLft,h4wRgt,h4wBas,h4wTop,h4sLft,h4sRgt DECLARE PUBLIC h4fLft,h4fRgt,h4First,h4STik,h4LTik,h4Label DECLARE PUBLIC h4name$,h4m,h4form$,h4clr LET h4clr = white LET h4name$ = "k" LET h4form$ = "--%.##" LET h4m = 1 LET h4axis = h1axis+ 50 LET h4wLft = h1wLft LET h4wRgt = h4wLft+200 LET h4fLft = 0 LET h4fRgt = 4 LET h4STik = 0.5 LET h4LTik = 1 LET h4Label= 1 LET h4First= h4fLft CALL HSlider4Variables ! ---------- Text Output Rects ---------- ! --- text rectangle 1 --- LET txt$ = "p(D)x = x'' + bx' + kx = k cos(wt)" CALL StringWidth(txt$,sw) LET t1BasLn = w2Top+10 LET t1Lft = w1midX-sw/2 LET t1Rgt = t1Lft + 180 LET t1Bas = t1BasLn + 5 LET t1Top = t1BasLn - 15 LET t1wnx = t1Lft + 90 LET t1Label$= "" SUB t1Label CALL SuperSubScriptRJ(t1Lft,t1BasLn,t1Label$,white) END SUB SUB t1Set CALL t1Clear CALL SwapOmega(t1Lft,t1BasLn,txt$,"w",white) END SUB SUB t1Clear BOX CLEAR t1Lft-2,t1Rgt,t1Bas,t1Top END SUB SUB t1Init !CALL t1Label CALL t1Set END SUB ! --- text rectangle 2 --- LET t2BasLn = w5Bas+35 LET t2Lft = w5Lft LET t2Rgt = w5Rgt LET t2Bas = t2BasLn + 5 LET t2Top = t2BasLn - 15 LET t2Label$= "" SUB t2Label CALL PlotTextRJ(t2Lft,t2Bas,t2Label$,white) END SUB SUB t2Set CALL SetTextFont(1,12,"bold") CALL t2Clear CALL SwapOmega(t2Lft,t2BasLn,"k/p(iw)","w",white) END SUB SUB t2Clear BOX CLEAR t2Lft-2,t2Rgt,t2Bas,t2Top END SUB SUB t2Init CALL t2Label CALL t2Set END SUB ! --- text rectangle 3 --- LET t3BasLn = h4Axis + 60 LET t3Lft = w1Lft+15 LET t3Rgt = t3Lft + 150 LET t3Bas = t3BasLn + 5 LET t3Top = t3BasLn - 15 LET t3Label$= "P = " SUB t3Label CALL SetTextFont(1,12,"bold") CALL SuperSubScriptRJ(t3Lft,t3BasLn,t3Label$,white) END SUB SUB t3Set CALL SetTextFont(1,12,"bold") CALL t3Clear LET t$= "2pi/w" !CALL PlotTextLJ(t3Lft,t3BasLn,t$,white) CALL StringWidth("2m",sw) CALL SwapPi(t3Lft,t3BasLn,"2p","p",white) LET lft = t3Lft + sw CALL SwapOmega(t3Lft+sw,t3BasLn,"/w","w",white) CALL StringWidth("/w",sw) LET t3vEqx = lft + sw + 12 CALL PlotTextRJ(t3vEqx,t3BasLn,"=",white) LET t3vLft = t3vEqx + 4 LET t3vRgt = t3vLft + 100 END SUB SUB t3Val BOX CLEAR t3vLft,t3vRgt,t3Bas,t3Top CALL SetTextFont(1,12,"bold") IF w>0 then LET t$ = using$("---%.##",2*pi/w) ELSE LET t$ = "undefined" END IF CALL PlotTextLJ(t3vLft,t3BasLn,t$,white) END SUB SUB t3Clear BOX CLEAR t3Lft-2,t3Rgt,t3Bas,t3Top END SUB SUB t3Init CALL t3Label CALL t3Set CALL t3Val END SUB ! --- text rectangle 4 --- ! timelag = period*phi/(2*pi) LET t4BasLn = t3BasLn + 40 LET t4Lft = w1Lft + 15 LET t4Rgt = t3Lft + 150 LET t4Bas = t4BasLn + 5 LET t4Top = t4BasLn - 15 LET t4Label$= "t_[0] = " SUB t4Label CALL SetTextFont(1,12,"bold") CALL SuperSubScriptRJ(t4Lft+2,t4BasLn,t4Label$,red) END SUB SUB t4Init CALL t4Label CALL t4Set CALL t4Val END SUB SUB t4Set CALL t4Clear CALL SetTextFont(1,12,"bold") LET t$= "(phi/2pi)P" !LET t$= trim$(using$("---%.##",timeLag)) !CALL PlotTextLJ(t4Lft,t4BasLn,t$,red) CALL StringWidth("(0",sw) CALL SwapPhi(t4Lft,t4BasLn,"(p","p",red) LET lft = t4Lft + sw CALL SwapPi(lft,t4BasLn,"/2p)P","p",red) CALL StringWidth("/2p)P",sw) LET t4vEqx = lft + sw + 14 CALL PlotTextRJ(t4vEqx,t4BasLn,"=",red) LET t4vLft = t4vEqx + 4 LET t4vRgt = t4vLft + 100 END SUB SUB t4Val BOX CLEAR t4vLft,t4vRgt,t4Bas,t4Top CALL SetTextFont(1,12,"bold") LET lag = phi/w IF w>0 then LET t$ = using$("---%.##",lag) ELSE LET t$ = "undefined" END IF CALL PlotTextLJ(t4vLft,t4BasLn,t$,red) END SUB SUB t4Clear BOX CLEAR t4Lft-2,t4Rgt,t4Bas,t4Top END SUB ! --- Draw the screen --- LET dt = 1/16 ! time step LET ascl= wHgt/4-10 ! same as 1 in graph LET m = 1 ! mass LET k = 1 ! spring constant LET b = 0.5 ! damping LET w = 1 LET f = 1 LET phi= fphi(w) CALL InitScreen SUB InitScreen BOX CLEAR worklft,workrgt,workbas,worktop LET vfieldflag= 0 LET sfieldflag= 0 LET iclr= cyan LET rclr= yellow IF colorscheme=1 then LET aclr= red ! envelope LET bclr= blue ! wave LET cclr= green ! complex points LET slideclr= drkgry ! slider names LET gridclr = litmid ELSE LET aclr= yellow ! envelope LET bclr= cyan ! wave LET cclr= green ! complex points LET slideclr= litgry ! slider names LET gridclr = drkmid END IF LET posclr= yellow LET velclr= cyan LET phsclr= red LET wclr = 10 LET rclr = 9 LET ampclr= cyan LET phiclr= green LET frcClr= blue LET lagClr= 3 CALL Plane1Init CALL Plane2Init CALL Plane3Init CALL Plane4Init CALL Plane5Init CALL t1Init CALL t2Init CALL t3Init CALL t4Init LET b = 0.5 LET w = 1 LET c = 1 LET t = 0 CALL h1DrawSlider(b) CALL h2DrawSlider(w) CALL SwapOmega(h2wLft-15,h2wBas-4,"w","w",white) ! CALL h3DrawSlider(c) ! CALL SwapOmega(h3wLft-21,h3wBas-4,"w","w",white) ! CALL SetTextFont(1,9,"bold") ! CALL PlotTextLJ(h3wLft-10,h3wBas-1,"n",white) CALL h4DrawSlider(k) CALL Buttons CALL DrawSpringStand LET pos,pos0= 0 CALL ReDrawGraphs CALL DrawMass(0,w1y0) CALL SetTimer END SUB ! ----------------- Event manager ----------------- DO IF ms<>2 then CALL MouseDown(mx,my,ms) END IF IF mx>=w1Lft-2 and mx<=w1Rgt+2 and my>w1Top and my=h1wLft-2 and mx<=h1wRgt+2 and my>h1wTop and myoldb then LET oldb= b CALL h1Mark(b) CALL ReDrawGraphs END IF LOOP until ms=3 BOX KEEP w1Lft-5,w1Rgt+5,w1Bas+5,w1Top-5 in w1graphLayer$ ELSE IF mx>=h2wLft-2 and mx<=h2wRgt+2 and my>h2wTop and myoldw then LET oldw= w CALL h2Mark(w) CALL SetAmplitude CALL SetPhi CALL APhiGraph CALL ShowLag CALL t3Val CALL t4Val END IF LOOP until ms=3 ! CALL SetAmplitude ! ELSE IF mx>=h3wLft-2 and mx<=h3wRgt+2 and my>h3wTop and myoldc then ! LET oldc= c ! CALL h3Mark(c) ! ! CALL ReDrawGraphs ! END IF ! LOOP until ms=3 ! BOX KEEP w1Lft-5,w1Rgt+5,w1Bas+5,w1Top-5 in w1graphLayer$ ELSE IF mx>=h4wLft-2 and mx<=h4wRgt+2 and my>h4wTop and myoldk then LET oldk= k CALL h4Mark(k) CALL SetAmplitude CALL SetPhi CALL APhiGraph CALL ShowLag CALL t4Val CALL ReDrawGraphs END IF LOOP until ms=3 BOX KEEP w1Lft-5,w1Rgt+5,w1Bas+5,w1Top-5 in w1graphLayer$ ELSE IF mx>=golft-2 and mx<=gorgt+2 and my>gotop and my=pclft-2 and mx<=pcrgt+2 and my>gotop and myinfLft and mxinfTop and myqLft and mxqTop and myolds and tx>w1Lft+20 then ! LET philft= tx ! LET phiwy = wy ! EXIT FOR ! END IF ! NEXT tx ! IF w<>0 and philft>w1fLft then IF w>0 then LET lag = phi/w/pi !LET phix= lag * w1wWid/w1fWid LET phix= w1Wndx(lag) !set color green !print lag LET tx = w1Lft LET phirgt= phix !tx+phix-1 IF phirgtpclft and mxgotop and mypclft and mxgotop and my1/60 ! CALL Delay(1/64) LOOP until ms=2 BOX CLEAR pclft,pcrgt,gobas,gotop ! CALL DrawButton(pclft,pcrgt,gobas,gotop,4,"Continue") END SUB SUB DrawMass(fy,wpy) ! LET stop = frcy + unit*(f - f*cos(w*t)) + 8 LET stop = frcy + unit*(1 - cos(w*t)) + 8 ! LET stop = frcy LET sdst = wpy - stop ! when forced LET seg = (sdst-shgt2)/segs LET seg14= .25*seg LET seg34= .75*seg LET sbas = stop+sdst - shgt2 LET mtop = sbas LET mbas = sbas+shgt LET dbas = mbas+w1wHgt LET wmy = (mtop+mbas)/2 BOX SHOW symboxb1$ at slft,w2Bas LET sprClr= 4 ! draw spring SET COLOR sprClr FOR i= 0 to segs-1 LET pnt= stop + i*seg - 1 PLOT w2Midx,pnt; splft,pnt+seg14; sprgt,pnt+seg34; w2Midx,pnt+seg NEXT i SET COLOR blue ! forcing plunger BOX AREA slft+8,srgt-8,stop-1,stop-8 BOX AREA dlft+8,drgt-8,stop-7,ceiling BOX SHOW mass$ at slft+8,mbas BOX SHOW damp$ at dlft,dbas ! LET ahgt= fy*ascl ! draw forces ! SET COLOR frcClr ! IF ahgt>1 then ! up ! LET top= wmy-ahgt ! BOX AREA llft,lrgt,wmy-1,top ! PLOT llft-1,top+2; llft+1,top-1; lrgt+1,top+2 ! ! BOX AREA rlft,rrgt,wmy-1,top ! PLOT rlft-1,top+2; rlft+1,top-1; rrgt+1,top+2 ! ELSE IF ahgt<-1 then ! down ! LET bas= wmy-ahgt ! BOX AREA llft,lrgt,wmy-ahgt,wmy+1 ! PLOT llft-1,bas-2; llft+1,bas+1; lrgt+1,bas-2 ! ! BOX AREA rlft,rrgt,wmy-ahgt,wmy+1 ! PLOT rlft-1,bas-2; rlft+1,bas+1; rrgt+1,bas-2 ! END IF END SUB ! --- VibrationAmplitude Graphics --- SUB DrawSpringStand LET slft= w2Midx-16 ! mass LET srgt= w2Midx+16 LET llft= slft+2 ! force arrows LET lrgt= llft+2 LET rlft= srgt-4 LET rrgt= rlft+2 LET dlft = w2Midx-5 ! dashpot LET drgt = w2Midx+5 LET dmplft= dlft+4 LET dmprgt= drgt-4 LET shgt = 10 LET ceiling= w2Top+10 LET floor = w2Bas-10 LET shgt2= shgt/2 LET shlft= w2Lft+10 LET shrgt= w2Rgt-10 LET shbas= w2Bas-10 LET shtop= w2Top+22 LET splft= slft+12 ! spring bounds LET sprgt= srgt-12 LET dbas = mbas+w1wHgt LET segs = 8 LET unit = w1wHgt/w1fHgt - 8 LET frcy = ceiling !+10 LET stop = frcy SET COLOR black ! draw the box BOX AREA w2Lft,w2Rgt,w2Bas,w2Top SET COLOR litmid BOX LINES w2Lft,w2Rgt,w2Bas,w2Top SET COLOR 13 BOX AREA w2Lft+1,w2Rgt-1,ceiling-1,w2Top+1 ! draw the ceiling BOX AREA w2Lft+1,w2Rgt-1,floor+1,w2Bas-1 ! draw the floor BOX AREA dlft-3,drgt+3,floor,w1Bas+8 ! draw the dashpot SET COLOR black BOX AREA dlft,drgt,floor,w1Bas BOX KEEP slft,srgt,w2Bas,w2Top in symboxb1$ LET mbas= w1y0+5 SET COLOR posclr ! mass !PLOT slft,w1y0; srgt,w1y0 BOX AREA slft+8,srgt-8,mbas,w1y0-5 BOX KEEP slft+8,srgt-8,mbas,w1y0-5 in mass$ LET dbas = mbas+w1wHgt SET COLOR litmid ! damper BOX AREA dmplft,dmprgt,dbas,mbas+1 BOX AREA dlft,drgt,dbas,dbas-2 BOX KEEP dlft,drgt,dbas,mbas+1 in damp$ END SUB ! PICTURE ForceArrow(ahgt) ! PLOT AREA: -2,0; -2,-ahgt; -4,-ahgt; 0,-ahgt-4; 4,-ahgt; 2,-ahgt; 2,0 ! END PICTURE ! PICTURE ForceArrowN(ahgt) ! PLOT AREA: -2,0; -2,-ahgt; -4,-ahgt; 0,-ahgt+4; 4,-ahgt; 2,-ahgt; 2,0 ! END PICTURE SUB ResetTimeGraph LET w1fLft= 0 LET w1fRgt= w1fLft+w1fWid CALL Plane1Variables CALL PiLabels END SUB SUB AdvanceTimeGraph LET w1fLft = w1fLft + w1fWid LET w1fRgt = w1fLft + w1fWid CALL Plane1Variables CALL PiLabels END SUB SUB PiLabels BOX CLEAR w1Lft-20,w1Rgt+20,w1Bas+15,w1Bas+5 CALL SetTextFont(1,9,"normal") LET wy= w1Bas+13 FOR i= w1fLft to w1fRgt step 2 LET wx= w1Wndx(i) SELECT CASE i CASE 0 LET n$= "0" CALL PlotTextCJ(wx,wy,"0",white) CASE else CALL PlotTextRJ(wx,wy,str$(i),white) DRAW Pi9 with shift (wx+1,wy) END SELECT NEXT i END SUB ! SUB SqrtSign(sx,sy,swid,sclr) ! LET shgt= 16 ! SET COLOR sclr ! PLOT sx,sy-8; sx+4,sy; sx+12,sy-shgt ! PLOT sx+12,sy-shgt-1; sx+9+swid,sy-shgt-1 ! END SUB ! SUB VectorField ! SET COLOR 10 ! BOX AREA w1Lft+1,w1Rgt,w1Bas-1,w1Top ! SET COLOR 12 ! PLOT w1Lft+1,w1Top; w1Rgt,w1Top; w1Rgt,w1Bas-1 ! SET COLOR 13 ! FOR wx= w1Lft+12 to w1Rgt-5 step 16 ! FOR wy= w1Top+12 to w1Bas-5 step 16 ! LET pos,pos1= w1Fncy(wy) ! LET vel,vel1= 0 !w1Fncx(wx) ! CALL RungeKutta4(pos1,vel1) ! LET dx= dt ! ! LET dy= w1Wndy(pos1)-w1Wndy(pos) ! ! LET dx= w1Wndx(vel1)-w1Wndx(vel) ! IF dx<>0 or dy<>0 then ! LET ang= angle(dx,dy) ! DRAW vector with rotate(ang) * shift(wx,wy) ! END IF ! NEXT wy ! NEXT wx ! CALL ZeroAxes(w1fLft,w1fRgt,w1fBas,w1fTop,w1Lft,w1Rgt,w1Bas,w1Top,2) ! !BOX KEEP w1Lft-2,w1Rgt+2,w1Bas+2,w1Top-2 in graph$ ! BOX KEEP w1Lft,w1Rgt,w1Bas,w1Top in graph$ ! END SUB ! ! SUB CharEq(lx,ly,clr) ! CALL SetTextFont(1,12,"bold") ! SET COLOR 1 ! CALL DrawLam (lx,ly,clr) ! CALL SetTextFont(1,9,"bold") ! CALL PlotTextLJ(lx+8,ly-5,"2",1) ! CALL SetTextFont(1,12,"bold") ! CALL PlotTextLJ(lx+15,ly," + 2b",1) ! LET lamx=lx+50 ! CALL DrawLam (lx+51,ly,clr) ! CALL PlotTextLJ(lx+60,ly," + 1 ",1) ! CALL PlotTextLJ(lx+92,ly-1,"=",1) ! CALL PlotTextLJ(lx+101,ly," 0",1) ! END SUB SUB Buttons CALL SetTextFont(1,9,"bold") LET golft= w1Lft LET gorgt= golft+35 LET gotop= w1Bas+25 LET gobas= gotop+14 CALL DrawButton(golft,gorgt,gobas,gotop,4,"Start") LET cntlft= w1Rgt-75 LET cntrgt= cntlft+75 LET cnttop= gotop LET cntbas= gobas ! CALL DrawButton(cntlft,cntrgt,cntbas,cnttop,4,"Continue") LET pclft= w1Rgt-55 LET pcrgt= pclft+55 LET pctop= gotop LET pcbas= gobas END SUB END SUB ! --- end of tool code -------------------