! When z = 0, the yellow line should vanish altogether from both ! windows. ! ! When the a slider is in use, a dark blue line should appear on ! the left screen, the line Im z = b - as it does. The image of ! this line is a ray from the origin in the e^z plane, not a line ! through the origin as drawn. This is my oversight, faithfully ! reproduced by you and then Ashot. ! I keep wondering about what symbols or ! pictures are needed to actually understand what is going ! on in this one. It creates a mystery and doesn't explain ! itself. ! Maybe it takes a preliminary picture to show how the ! conversion to polar coordinates happens, and maybe another ! picture that shows an application. ! given a complex value a+ib and its exponential e^(a+ib) ! e^(a+ib) = e^a * e^ib ! but Euler showed that e^ib = (cos(b) + i sin(b) so ! e^(a+ib) = e^a * (cos(b) + i sin(b)) ! now distribute e^a ! e^(a+ib) = e^a * cos(b) + e^a * i sin(b) ! e^a * cos(b) + e^a * i sin(b) is a complex value so ! we can separate the real and imaginary parts of e^(a+ib) ! re = e^a * cos(b) ! im = e^a * i sin(b) ! but graphically, i just means "on the complex vertical axis" so ! re = e^a * cos(b) ! on x ! im = e^a * sin(b) ! on y ! so e^a is the radius, and b is the angle, for the ! point that represents e^(a+ib) on the complex plane ! we don't help students understand this in the pictures ! or the symbols. I was trying to find a way. I have a version ! with symbolic steps, but I know you don't like showing the ! symbols, so I was trying to find graphics to suggest that I ! am using ! x = e^a * cos(b) ! y = e^a * sin(b) ! behind the scenes. Will they automatically know how to use ! Euler's formula to understand how to get to the polar coordinates? ! I thought that if a remedial tool is actually needed at this ! level, then they might not know about Euler's Formula. !! File: ComplexExponential.68k !! Jume 27, 2003 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 backclr,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 LET toolHgt= 560 LET toolWid= 780 LET window$= "The d'Arbeloff Interactive Math Project" LET colorscheme= 0 LET title$ = "Complex Exponentials" SUB ThisProgram CALL ComplexExponential 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 --- !library "HHLib.unix" !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 ------ ! ----------------------------------------------------------- ! *** SUB ComplexExponential DECLARE PUBLIC worklft,workrgt,workbas,worktop,workmid ! work area DECLARE PUBLIC black,drkgry,drkmid,midgry,litmid,litgry,white DECLARE PUBLIC red,yellow,green,cyan,blue,magenta,colorscheme DECLARE PUBLIC slideclr,axislabelclr,true,false DECLARE DEF InfoWithin, QuitWithin ! --- help screen array --- DIM info$(1:20) MAT READ info$ DATA "Complex Exponentials" DATA "" DATA "This tool supports visual exploration of the relationships between complex values on the z plane and their corresponding complex exponentials on the e^[z] plane." DATA "" DATA "Given a complex value a+ib and its exponential e^[a+ib]" DATA "-e^[a+ib] = e^[a] e^[ib]" DATA "Euler showed that e^[ib] = cos(b) + i sin(b) so" DATA "-e^[a+ib] = e^[a] (cos(b) + i sin(b))" DATA "-e^[a+ib] = e^[a] cos(b) + e^[a] i sin(b)" DATA "To plot the point, we separate the real and imaginary parts" DATA "-re = e^[a] cos(b)" DATA "-im = e^[a] i sin(b)" DATA "and this is a conversion from polar to cartesian coordinates, where" DATA "e^[a] is the radius and b is the angle." DATA "When graphing, the i refers to the imaginary vertical axis, so we plot" DATA "-re = e^[a] cos(b) on the horizontal axis" DATA "-im = e^[a] sin(b) on the vertical axis" DATA "" DATA "To set the input value, click or drag the mouse in the z plane, or use the a and b sliders." DATA "Drag the t slider to see corresponding points on the two planes." ! ---------- Utility functions --- DECLARE DEF clamp,roundn,e ! ---- Functions ---- DEF cs(a,b,t) = e^(a*t) * cos(b*t) DEF sn(a,b,t) = e^(a*t) * sin(b*t) SUB ComplexExpVal(a,b,t,x,y) LET rad= e^(a*t) LET bt = b*t LET x = rad * cos(bt) LET y = rad * sin(bt) END SUB ! ---------- Graphing plane parameters and methods ---------- LET wsize = 288 ! --- w1 plane 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 = 1 LET w1xPiFlag= 0 LET w1xMult = 1 LET w1yPiFlag= 0 LET w1yMult = 1 LET w1Lft = workrgt - 340 ! pixel bounds LET w1Rgt = w1Lft + wsize LET w1Top = workTop + 55 LET w1Bas = w1Top + wsize LET fsize = 3 LET w1fLft= -fsize ! function bounds LET w1fRgt= fsize LET w1fTop= fsize LET w1fBas= -fsize LET w1xAx$= "Re" ! axis labels LET w1yAx$= "Im" LET w1xGridstep= 1 ! horizontal grid intervals LET w1yGridstep= 1 ! vertical grid intervals LET w1xSTik = 0 ! horizontal axis Tik marks LET w1xLTik = 1 LET w1xLabel= 1 LET w1xFirst= w1fLft LET w1ySTik = 0 ! vertical axis Tik marks LET w1yLTik = 1 LET w1yLabel= 1 LET w1yFirst= w1fBas ! --- w1 Plane methods --- DECLARE DEF w1fncx,w1fncy,w1wndx,w1wndy ! window/function transforms DECLARE DEF w1wWithin,w1Within !,w1fWithin CALL w1Variables LET w1x1 = w1Wndx(1) LET w1pix= w1wxratio SUB w1Init CALL w1DrawPlane(1,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$,axislabelclr) CALL PlotDiamondClr(w1x1,w1y0,red) CALL w1KeepGridLayer CALL SuperSubScriptCJ(w1Midx,w1Top-30,"e^[z] plane",white) END SUB ! --- w2 plane data --- DECLARE PUBLIC w2Lft,w2Rgt,w2Bas,w2Top,w2Midx,w2Midy DECLARE PUBLIC w2fLft,w2fRgt,w2fBas,w2fTop,w2x0,w2y0 DECLARE PUBLIC w2xFirst, w2xSTik, w2xLTik, w2xLabel, w2xGridstep DECLARE PUBLIC w2yFirst, w2ySTik, w2yLTik, w2yLabel, w2yGridstep DECLARE PUBLIC w2wWid,w2wHgt,w2fWid,w2fHgt DECLARE PUBLIC w2fxRatio,w2fyRatio,w2wxRatio,w2wyRatio,w2Aspect DECLARE PUBLIC w2xPiFlag, w2xMult, w2yPiFlag, w2yMult LET w2Flag = 1 LET w2xPiFlag= 0 LET w2xMult = 1 LET w2yPiFlag= 0 LET w2yMult = 1 LET w2Lft = worklft + 50 ! pixel bounds LET w2Rgt = w2Lft + wsize LET w2Top = w1Top LET w2Bas = w2Top + wsize LET w2fLft= -1 ! function bounds LET w2fRgt= 1 LET w2fTop= 8 LET w2fBas= -8 LET w2xAx$= "a" ! axis labels LET w2yAx$= "b" LET w2xGridstep= 0.5 ! grid line intervals LET w2yGridstep= 4 LET w2xSTik = 0 ! axis Tik marks LET w2xLTik = 0.5 LET w2xLabel= 0.5 LET w2xFirst= w2fLft LET w2ySTik = 0 LET w2yLTik = 4 LET w2yLabel= 4 LET w2yFirst= w2fBas ! --- w2 plane methods --- DECLARE DEF w2fncx,w2fncy,w2wndx,w2wndy ! window/function transforms DECLARE DEF w2wWithin,w2Within CALL w2Variables SUB w2Init CALL w2DrawPlane(1,1,1) ! grid, axes, zeroaxes CALL SetTextFont(1,12,"bold") CALL PlotTextLJ(w2Rgt+8,w2y0+3,w2xAx$,axislabelclr) ! axis labels CALL PlotTextCJ(w2x0,w2Top-10,w2yAx$,axislabelclr) CALL PlotTextCJ(w2Midx,w2Top-30,"z plane",white) CALL PlotDiamondClr(w2x0,w2y0,red) CALL w2KeepGridLayer END SUB ! --- horizontal sliders --- ! --- h1 slider - a value --- 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$ = "a" LET h1form$ = "-%.##" LET h1Places= 2 LET h1Click = 0.1 LET h1axis = workbas - 75 LET h1wLft = w2Lft LET h1wRgt = h1wLft + wsize LET h1fLft = -1 LET h1fRgt = 1 LET h1STik = .1 LET h1LTik = .5 LET h1Label = .5 LET h1First = h1fLft CALL h1SliderVariables ! --- h1 slider methods --- DECLARE DEF h1Within SUB h1Init CALL h1DrawSlider(h1name$,a) END SUB ! --- h2 slider - b value --- 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$ = "b" LET h2form$ = "-%.##" LET h2Places= 2 LET h2Click = pi/4 LET h2axis = h1axis + 45 LET h2wLft = h1wLft LET h2wRgt = h1wRgt LET h2fLft = -8 LET h2fRgt = 8 LET h2STik = 1 LET h2LTik = 4 LET h2Label = 4 LET h2First = h2fLft CALL h2SliderVariables DECLARE DEF h2Within ! window/function transforms SUB h2Init CALL h2DrawSlider(h2name$,b) END SUB ! --- h3 slider - t parameter --- 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 = yellow !slideclr LET h3name$ = "t" LET h3form$ = "-%.##" LET h3Places= 2 LET h3Click = 0.1 LET h3axis = h1axis LET h3wLft = w1Midx LET h3wRgt = h3wLft + 100 LET h3fLft = 0 LET h3fRgt = 1 LET h3STik = 0.1 LET h3LTik = 0.5 LET h3Label = 0.5 LET h3First = h3fLft CALL h3SliderVariables DECLARE DEF h3Within ! window/function transforms SUB h3Init CALL h3DrawSlider(h3name$,t) END SUB ! ---------- Text Output Rects ---------- ! --- text rectangle 1 - complex expressions --- LET t1BasLn1= w1Bas + 35 LET t1BasLn2= t1BasLn1 + 25 LET t1Lft = w1Lft LET t1Rgt = w1Rgt - 80 LET t1Bas = t1BasLn1 + 5 LET t1Top = t1BasLn1 - 15 LET t1Label$= "e^[a + bi] = " CALL SetTextFont(1,12,"bold") CALL StringWidth("e = ",sw1) CALL SetTextFont(1, 9,"bold") CALL StringWidth("a + bi",sw2) LET t1Eqx= t1Lft + sw1 + sw2 SUB t1Label CALL SuperSubScriptRJ(t1Eqx,t1BasLn1,t1Label$,cyan) CALL SuperSubScriptLJ(t1Lft,t1BasLn2,"e^[(a + bi)t]",yellow) END SUB SUB t1Value(x,y) CALL t1Clear CALL CmplxStringTrim(cmplx$,x,y) ! Numeric to text CALL SuperSubScriptLJ(t1Eqx,t1BasLn1,cmplx$,cyan) END SUB SUB t1Clear BOX CLEAR t1Eqx,t1Rgt,t1Bas,t1Top END SUB SUB t1Init CALL t1Label END SUB ! --- text rectangle 2 - complex time expressions --- LET t2BasLn1= t1BasLn1 LET t2BasLn2= t1BasLn2 LET t2Lft = w2Lft LET t2Rgt = w2Rgt - 80 LET t2Bas = t2BasLn1 + 5 LET t2Top = t2BasLn1 - 15 LET t2Label$= "a + bi = " CALL SetTextFont(1,12,"bold") CALL StringWidth(t2Label$,sw) LET t2eqx = t2Lft + sw SUB t2Label CALL PlotTextRJ(t2Eqx,t2BasLn1,t2Label$,cyan) CALL PlotTextLJ(t2Lft,t1BasLn2,"(a + bi)t",yellow) END SUB SUB t2Value(x,y) CALL t2Clear CALL CmplxStringTrim(cmplx$,a,b) ! Numeric to text CALL PlotTextLJ(t2eqx,t2BasLn1,cmplx$,cyan) END SUB SUB t2Clear BOX CLEAR t2Eqx,t2Rgt,t2Bas,t2Top END SUB SUB t2Init CALL t2Label END SUB ! --- t3 equation steps (not used in Mit version) --- LET t3BasLn = w1Bas + 90 LET t3LnSpc = 18 LET t3Lft = w1Lft LET t3Rgt = w1Rgt - 60 LET t3Bas = t3BasLn + 4*t3LnSpc + 5 LET t3Top = t3BasLn - 15 LET t3Label$= "e^[a + bi] = " LET t3Eqx = t1Lft + 70 LET t3bLft= w1Rgt-55 LET t3bRgt= t3bLft+55 LET t3bBas= t3Bas LET t3bTop= t3bBas-20 SUB t3Clear BOX CLEAR t3lft,t3Rgt,t3Bas,t3Top END SUB SUB t3Button CALL SetTextFont(1,12,"bold") CALL DrawButton(t3bLft,t3bRgt,t3bBas,t3bTop,6,"Steps") END SUB SUB t3Set ! e^(a+bi) = e^a e^bi CALL SuperSubScriptRJ(t3Eqx,t3BasLn+0*t3LnSpc,t3Label$,cyan) CALL SuperSubScriptLJ(t3Eqx,t3BasLn+0*t3LnSpc,"e^[a] e^[ib]",cyan) ! e^(a+ib) = e^a (cos(b) + i sin(b)) ! euler's formula CALL SuperSubScriptRJ(t3Eqx,t3BasLn+1*t3LnSpc,"= ",cyan) CALL SuperSubScriptLJ(t3Eqx,t3BasLn+1*t3LnSpc,"e^[a] (cos(b) + i sin(b))",cyan) ! e^(a+ib) = e^a cos(b) + i e^a sin(b) CALL SuperSubScriptRJ(t3Eqx,t3BasLn+2*t3LnSpc,"= ",cyan) CALL SuperSubScriptLJ(t3Eqx,t3BasLn+2*t3LnSpc,"e^[a] cos(b) + i e^[a] sin(b)",cyan) ! re = e^a * cos(b) CALL SuperSubScriptRJ(t3Eqx,t3BasLn+3*t3LnSpc,"Re = ",cyan) CALL SuperSubScriptLJ(t3Eqx,t3BasLn+3*t3LnSpc,"e^[a] cos(b)",cyan) ! im = i e^a * i sin(b) CALL SuperSubScriptRJ(t3Eqx,t3BasLn+4*t3LnSpc,"Im = ",cyan) CALL SuperSubScriptLJ(t3Eqx,t3BasLn+4*t3LnSpc,"i e^[a] sin (b)",cyan) END SUB ! --- default parameters --- LET maxa = w2fRgt LET maxb = w2fTop LET a,olda = 0.5 LET b,oldb = pi LET t,oldt = 0 LET t3State= 0 ! --- draw the screen --- CALL InitScreen SUB InitScreen BOX CLEAR worklft,workrgt,workbas,worktop CALL w1Init CALL w2Init CALL t1Init CALL t2Init CALL h1Init CALL h2Init CALL h3Init CALL DrawingVariables(a,b,x1,y1,x2,y2,wx1,wy1,wx2,wy2,w1c1,w1s1) CALL DrawGraphs(yellow) END SUB ! ----------------- Event manager ----------------- DO DO GET MOUSE: mx,my,ms LOOP until ms=2 IF w2Within(mx,my)=true then CALL h3ResetTime CALL w2MouseEvent(mx,my) ELSE IF h1Within(mx,my)=true then CALL h3ResetTime IF myt3bLft and mxt3bTop and myolda or b<>oldb then CALL h1Mark(a) CALL h2Mark(b) CALL w2MouseAction CALL SetVars(a,b,olda,oldb) END IF LOOP until ms=3 CALL DrawGraphs(yellow) END SUB SUB w2MouseAction LOCAL x,y ! sketch line CALL w2ShowGridLayer CALL DrawingVariables(a,b,x1,y1,x2,y2,wx1,wy1,wx2,wy2,w1c1,w1s1) CALL PlotLinePoint(w2x0,w2y0,w2Wa,w2Wb,yellow,cyan) ! sketch exponential spiral CALL w1ShowGridLayer CALL FastSpiral END SUB ! ---- Slider Event Methods ---- ! ----- slider 1 - a value ----- SUB h1ClickEvent(ms) CALL h1GetClickVal(ms,h1Click,a) CALL DrawGraphs(yellow) LET olda= a END SUB SUB h1DragEvent(ms) LET olda,oldb= -999 CALL w1ShowGridLayer CALL w2ShowGridLayer LET wy= w2Wndy(b) CALL PlotLine( w2Lft,wy, w2Rgt,wy, blue) CALL ComplexExpVal(a,b,1,x,y) LET rb= round(b,2) LET modb= round(mod(b,2*pi),2) IF rb= 6.28 then LET modb= 0 IF x<>0 then LET slope= y/x ! find the slope IF abs(slope)<=1 then ! clip right or left LET x1= w1fRgt LET x2= w1fLft LET y1= slope*x1 LET y2= slope*x2 IF modb3*pi/2 then LET x2= 0 LET y2= 0 ELSE LET x1= 0 LET y1= 0 END IF ELSE ! clip top or bottom LET y1= w1fTop LET y2= w1fBas LET x1= y1/slope LET x2= y2/slope IF modb>=0 and modbolda then CALL DrawFastGraphs(drkmid) LET olda= a END IF LOOP until ms=3 CALL DrawGraphs(yellow) END SUB ! --- slider 2 - b val --- SUB h2ClickEvent(ms) CALL h2GetClickVal(ms,h2Click,b) CALL DrawGraphs(yellow) LET oldb= b END SUB SUB h2DragEvent(ms) LET olda,oldb= -999 CALL h2GetDragVal(ms,h2Places,b) LET wx= w2Wndx(a) CALL w2ShowGridLayer CALL PlotLine( wx,w2Top, wx,w2Bas, blue) CALL ComplexExpVal(a,b,1,x,y) LET r = sqr(x*x + y*y) LET wr = r*w1pix CALL w1ShowGridLayer CALL BoxCircle (w1x0-wr,w1x0+wr,w1y0+wr,w1y0-wr,blue) CALL w1KeepGraphLayer CALL w2KeepGraphLayer DO CALL h2GetDragVal(ms,h2Places,b) IF b<>oldb then CALL DrawFastGraphs(drkmid) LET oldb= b END IF LOOP until ms=3 CALL DrawGraphs(yellow) END SUB ! --- slider 3 - t value --- SUB h3ResetTime LET t= 0 CALL h3Mark(t) END SUB SUB h3ClickEvent(ms) CALL h3GetClickVal(ms,h3Click,t) CALL h3Action END SUB SUB h3DragEvent(ms) CALL DrawGraphs(drkmid) DO CALL h3GetDragVal(ms,h3Places,t) CALL h3Action LOOP until ms=3 CALL DrawGraphs(yellow) CALL PlotDiamondClr(wx,wy,yellow) END SUB SUB h3Action IF t<>oldt then CALL SetVars(a*t,b*t,x,y) CALL w2MathToPixels(x,y,wx,wy) CALL w2ShowGraphLayer CALL PlotDiamondClr(wx,wy,yellow) CALL ComplexExpVal(a,b,t,x,y) ! e^(a+bi) CALL w1MathToPixels(x,y,wx,wy) SET COLOR yellow CALL w1ShowGraphLayer CALL PlotDiamondClr(wx,wy,yellow) LET oldt= t END IF END SUB ! --- Graph drawing methods --- SUB DrawFastGraphs(clr) ! real time response to sliders ! sketch linear input CALL FastLine(clr) ! sketch exponential spiral CALL w1ShowGraphLayer CALL FastSpiral END SUB SUB FastLine(clr) CALL DrawingVariables(a,b,x1,y1,x2,y2,wx1,wy1,wx2,wy2,w1c1,w1s1) CALL w2ShowGraphLayer CALL PlotLinePoint(w2x0,w2y0,w2Wa,w2Wb,yellow,cyan) END SUB SUB FastSpiral SET COLOR yellow FOR t1= 0 to 1 step 1/64 CALL ComplexExpVal(a,b,t1,x,y) CALL w1MathtoPixels(x,y,w1r2,w1i2) PLOT w1r2,w1i2; NEXT t1 PLOT CALL PlotDiamondClr(w1c1,w1s1,cyan) END SUB SUB DrawingVariables(a,b,x1,y1,x2,y2,wx1,wy1,wx2,wy2,w1c1,w1s1) ! left plane boundary intersects LOCAL slope,diag IF a<>0 then LET slope= b/a LET diag = maxb/maxa IF abs(slope)<=diag then ! clip left and right LET maxt= maxa/abs(a) LET x1 = -maxa LET x2 = maxa LET wx1 = w2Lft LET wx2 = w2Rgt LET y1 = x1*slope LET y2 = x2*slope LET wy1 = w2Wndy(y1) LET wy2 = w2Wndy(y2) ELSE IF abs(slope)>=diag then ! clip top and bas LET maxt= maxb/abs(b) LET y1 = maxb LET y2 = -maxb LET wy1 = w2Top LET wy2 = w2Bas LET x1 = y1/slope LET x2 = y2/slope LET wx1 = w2Wndx(x1) LET wx2 = w2Wndx(x2) END IF ELSE IF a=0 and b<>0 then ! vertical LET maxt = maxb/abs(b) LET x1,x2 = 0 LET wx1,wx2= w2x0 CALL SetVars(w2fBas,w2fTop, y1, y2) CALL SetVars(w2Bas ,w2Top , wy1,wy2) ELSE IF a=0 and b=0 then ! origin LET maxt = 1 LET x1,x2 = 0 LET y1,y2 = 0 LET wx1,wx2= w2x0 LET wy1,wy2= w2y0 END IF CALL ComplexExpVal(a,b,1,c1,s1) ! right complex values CALL w1MathtoPixels(c1,s1,w1c1,w1s1) CALL t1Value(c1,s1) ! left complex values CALL t2Value(a,b) CALL w2MathtoPixels(a,b,w2Wa,w2Wb) END SUB SUB DrawGraphs(clr) CALL DrawingVariables(a,b,x1,y1,x2,y2,wx1,wy1,wx2,wy2,w1c1,w1s1) CALL w2ShowGridLayer ! left line CALL PlotLine(wx1,wy1,wx2,wy2,clr) CALL PlotDiamondRimClr(w2Wa,w2Wb,cyan) ! restore points CALL PlotDiamondRimClr(w2x0,w2y0,red) CALL w1ShowGridLayer ! right spiral CALL PlotDiamondClr(w1c1,w1s1,cyan) SET COLOR clr FOR t1= -maxt to maxt step maxt/128 CALL ComplexExpVal(a,b,t1,x,y) ! get x and y CALL w1MathToPixels(x,y,w1r2,w1i2) PLOT w1r2,w1i2; NEXT t1 CALL ComplexExpVal(a,b,maxt,x,y) ! complete the spiral CALL w1MathToPixels(x,y,w1r2,w1i2) PLOT w1r2,w1i2 CALL PlotDiamondRimClr(w1x1,w1y0,red) CALL PlotDiamondRimClr(w1c1,w1s1,cyan) CALL w1KeepGraphLayer CALL w2KeepGraphLayer END SUB END SUB ! --- end of complex exponential code ---