function holo(action,input) if nargin == 0 action = 'initialize'; end if strcmp(action,'initialize') defval = 1; deffcn = ' exp(z)'; ss = get(0,'screensize'); ww = ss(3); ht = ss(4); left = 80; right = 30; fw = min(ww - left,840); aw = (fw-2*left-right)/2; ah = aw; top = 0; bott = 40; texth = 20; separation = texth + 7; wequals = 40; equatw = aw -wequals; fleft = ww - fw - left; fht = ah + top + bott + 4*separation; fbot = ht - fht - 50; abot = bott + 2*separation; ud.fig = figure('pos',[fleft,fbot,fw,fht],'name','Holomorphic Map',... 'numb','off','paperorient','landscape',... 'paperposition',[.25,2,10,5.5]); aleft = left/fw; awidth=aw/fw; abott = abot/fht; aheight = ah/fht; ud.zaxes = axes('pos',[aleft,abott,awidth,aheight],'next','add',... 'box','on','xgrid','on','ygrid','on',... 'xlim',[-4,4],'ylim',[-4,4]); xlabel('z - plane'); ud.zh = plot(1000,1000,'o','erase','xor','color','r'); ud.waxes = axes('pos',[2*aleft+awidth,abott,awidth,aheight],... 'next','add','box','on',... 'xgrid','on','ygrid','on','xlim',[-10,10],'ylim',[-10,10]); xlabel('w - plane'); title(['w = ',deffcn]); ud.wh = plot(1000,1000,'+','erase','xor','markersize',12,'linewidth',2.5,'color','r'); boxl = 50; tbott = separation; qleft = (fw - right-60); qbott = fht -25; clbutt = uicontrol('pos',[qleft,tbott,60,texth],... 'string','Clear','call','holo(''clear'')'); ud.qbutt = uicontrol('pos',[qleft,qbott,60,texth],... 'string','Quit','call','close'); weq = uicontrol('pos',[left,tbott,wequals,texth],... 'style','text','horiz','right','string','w = '); ud.fcns = uicontrol('pos',[left+wequals,tbott,equatw,texth],... 'style','edit','horiz','left','call','holo(''eqcall'')',... 'string',deffcn); ud.fcn = deffcn; set(ud.fcns,'user',deffcn); modew = 140; ud.modes = uicontrol('pos',[2*left+aw,tbott,modew,texth],... 'style','popup',... 'string','Points|Lines|Circles|Rectangular grid|Polar grid',... 'call','holo(''modecall'')','value',defval); ud.actbot = tbott + texth + 10; ud.acttop = abot + ah + 50; ud.colorder = get(0,'defaultaxescolororder'); ud.ptno = 0; ud.lineno = 0; ud.circno = 0; options = uimenu(ud.fig,'label','Opt&ions'); rect = uimenu(options,'label','Map a rectangular grid ...',... 'call','holo(''rectmap'')'); polar = uimenu(options,'label','Map a polar grid ...',... 'call','holo(''polarmap'')'); zchange = uimenu(options,'label','Change the z limits ...',... 'call','holo(''zchange'')'); wchange = uimenu(options,'label','Change the w limits ...',... 'call','holo(''wchange'')'); set(ud.fig,'user',ud); axes(ud.zaxes); set(ud.zaxes,'buttondownfcn','holo(''points'')'); set(ud.fig,'pointer','crosshair'); set(ud.fig,'windowbuttonmotionfcn','holo(''pointm'')'); elseif strcmp(action,'clear') ud = get(gcf,'user'); delete(findobj([ud.zaxes,ud.waxes],'tag','holoplot')); elseif strcmp(action,'eqcall') fig = gcf; ud = get(fig,'user'); fcnstr = get(gcbo,'string'); zax = ud.zaxes; wax = ud.waxes; wlabel = ['w = ',fcnstr]; l = length(fcnstr); for (k=fliplr(find((fcnstr == '^')|(fcnstr == '*')|(fcnstr == '/')))) fcnstr = [fcnstr(1:k-1) '.' fcnstr(k:l)]; l = l+1; end ud.fcn = fcnstr; set(fig,'user',ud); set(gcbo,'user',fcnstr); set(get(wax,'title'),'string',wlabel); delete(findobj([zax,wax],'tag','holoplot')); elseif strcmp(action,'modecall') fig = gcf; ud = get(fig,'user'); set(fig,'windowbuttonmotionfcn',''); mode = get(ud.modes,'value'); hh = ud.zaxes; if mode == 1 set(findobj(hh),'buttondownfcn','holo(''points'')'); set(gcf,'windowbuttonupfcn',' '); elseif mode == 2 set(findobj(hh),'buttondownfcn','holo(''lines'')'); elseif mode == 3 set(findobj(hh),'buttondownfcn','holo(''circles'')'); elseif mode == 4 set(findobj(hh),'buttondownfcn','holo(''rect'')'); elseif mode == 5 set(findobj(hh),'buttondownfcn','holo(''polar'')'); end set(fig,'windowbuttonmotionfcn','holo(''pointm'')'); elseif strcmp(action,'pointm') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); pt = get(fig,'currentpoint'); ht = pt(2); if ht > ud.actbot & ht < ud.acttop set(fig,'pointer','crosshair'); point = get(ud.zaxes,'currentpoint'); point = point(1,[1,2]); z = point(1)+i*point(2); FFF = get(ud.fcns,'user'); w = eval(FFF); set(ud.wh,'xdata',real(w),'ydata',imag(w)); else set(fig,'pointer','arrow') end elseif strcmp(action,'points') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); col = ud.colorder(ud.ptno+1,:); ud.ptno = rem(ud.ptno+1,size(ud.colorder,1)); point = get(ud.zaxes,'currentpoint'); point = point(1,[1,2]); z = point(1)+i*point(2); plot(real(z),imag(z),'color',col,... 'parent',ud.zaxes,'tag','holoplot',... 'marker','.','markersize',12); w = eval(ud.fcn); plot(real(w),imag(w),'parent',ud.waxes,... 'color',col,'tag','holoplot',... 'marker','.','markersize',12); set(ud.zaxes,'buttondownfcn','holo(''points'')'); set(fig,'user',ud); elseif strcmp(action,'lines') % Line buttondownfcn fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); col = ud.colorder(ud.lineno+1,:); ud.lineno = rem(ud.lineno+1,size(ud.colorder,1)); zax = ud.zaxes; wax = ud.waxes; point = get(zax,'currentpoint'); point = point(1,[1,2]); z = point(1)+i*point(2); plot(real(z),imag(z),'.',... 'markersize',12,'color',col,... 'tag','holoplot','parent',zax); zlineh = plot(real([z,z]),imag([z,z]),'erase','xor',... 'parent',zax,'color',col,... 'tag','holoplot'); w = eval(ud.fcn); wlineh = plot(real([w,w]),imag([w,w]),'erase','xor',... 'parent',wax,'color',col,... 'tag','holoplot'); plot(real(w),imag(w),'.',... 'markersize',12,'color',col,... 'tag','holoplot','parent',wax); set(zax,'user',[z,zlineh,wlineh]) set(fig,'user',ud,... 'windowbuttonmotionfcn','holo(''linem'')',... 'windowbuttonupfcn','holo(''lineu'')'); elseif strcmp(action,'linem') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); pt = get(fig,'currentpoint'); if pt(2)>ud.actbot zax = ud.zaxes; set(fig,'pointer','custom',... 'pointershapecdata',NaN*ones(16)); set(ud.wh,'marker','none'); u = get(zax,'user'); z=u(1); zlineh = u(2); wlineh = u(3); wh = ud.wh; point = get(zax,'currentpoint'); point = point(1,[1,2]); z1 = point(1)+i*point(2); arrow = [-1+0.5i 0 -1-0.5i]; xlim = get(zax,'xlim'); ll = xlim(2) - xlim(1); zarr = z1 + ll*sign(z1-z)*arrow/30; zp = [z z1 zarr]; set(zlineh,'xdata',real(zp),'ydata',imag(zp),'linestyle','--'); z = z + (z1 - z)*linspace(0,1); FFF = ud.fcn; w = eval(FFF); xlim = get(ud.waxes,'xlim'); ll = xlim(2) - xlim(1); warr = w(100) + ll*sign(w(100) - w(99))*arrow/30; w = [w(:);warr(:)]; set(wlineh,'xdata',real(w),'ydata',imag(w),'linestyle','--'); z=z1;w=eval(FFF); set(wh,'xdata',real(w),'ydata',imag(w)); else set(fig,'pointer','arrow') end elseif strcmp(action,'lineu') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); u = get(ud.zaxes,'user'); z=u(1); zlineh = u(2); wlineh = u(3); zax = ud.zaxes; wax = ud.waxes; set(zlineh,'linestyle','-','erase','none','tag','holoplot'); set(wlineh,'linestyle','-','erase','none'); set(ud.wh,'marker','+'); set(fig,'windowbuttonmotionfcn','holo(''pointm'')',... 'windowbuttonupfcn','',... 'user',ud); set(findobj(zax),'buttondownfcn','holo(''lines'')'); elseif strcmp(action,'circles') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); col = ud.colorder(ud.circno+1,:); ud.circno = rem(ud.circno+1,size(ud.colorder,1)); zax = ud.zaxes; wax = ud.waxes; point = get(zax,'currentpoint'); point = point(1,[1,2]); z = point(1)+i*point(2); plot(real(z),imag(z),'tag','holoplot',... 'marker','.','markersize',12,... 'parent',zax,'color',col); circh = plot(real(z),imag(z),'erase','xor',... 'tag','holoplot','parent',zax,... 'color',col,'linestyle','--'); w = eval(ud.fcn); plot(real(w),imag(w),'tag','holoplot',... 'marker','.','markersize',12,... 'parent',wax,'color',col); wlineh = plot(real(w),imag(w),'erase','xor',... 'tag','holoplot','parent',wax,... 'color',col,'linestyle','--'); set(zax,'user',[z,circh,wlineh]); set(fig,'windowbuttonmotionfcn','holo(''circlem'')',... 'windowbuttonupfcn','holo(''circleu'')',... 'user',ud); elseif strcmp(action,'circlem') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); pt = get(fig,'currentpoint'); if pt(2)>ud.actbot set(fig,'pointer','crosshair'); zax = ud.zaxes; wax = ud.waxes; u = get(zax,'user'); cent = u(1); circh = u(2); wlineh = u(3); wh = ud.wh; point = get(zax,'currentpoint'); point = point(1,[1,2]); z1 = point(1)+i*point(2); radius = abs(cent - z1); ang = exp(i*pi*(-1:(2/100):1)); z = cent+radius*ang; set(circh,'xdata',real(z),'ydata',imag(z)); FFF = ud.fcn; w = eval(FFF); set(wlineh,'xdata',real(w),'ydata',imag(w)); z=z1;w=eval(FFF); set(wh,'xdata',real(w),'ydata',imag(w),'marker','none'); else set(fig,'pointer','arrow') end elseif strcmp(action,'circleu') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); zax = ud.zaxes; u = get(zax,'user'); cent = u(1); circh = u(2); wlineh = u(3); col = get(circh,'color'); point = get(gca,'currentpoint'); point = point(1,[1,2]); z = point(1)+i*point(2); plot(real(z),imag(z),'.',... 'parent',zax,'markersize',12,... 'color',col,'tag','holoplot'); set(circh,'linestyle','-','erase','none'); w = eval(ud.fcn); plot(real(w),imag(w),'parent',ud.waxes,... 'marker','.','markersize',12,... 'color',col,'tag','holoplot'); set(wlineh,'linestyle','-','erase','none'); set(ud.wh,'marker','+'); set(fig,'windowbuttonmotionfcn','holo(''pointm'')',... 'windowbuttonupfcn','',... 'user',ud); set(findobj(zax),'buttondownfcn','holo(''circles'')'); elseif strcmp(action,'rect') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(gcf,'user'); zax = ud.zaxes; wax = ud.waxes; point = get(zax,'currentpoint'); point = point(1,[1,2]); z = point(1)+i*point(2); w = ud.fcn; % plot(real(z),imag(z),'parent',zax); zboxh = plot(real(z),imag(z),... 'parent',zax,'erasemode','xor',... 'tag','holoplot','linestyle','--'); wboxh = plot(real(w),imag(w),... 'parent',wax,'erase','xor',... 'tag','holoplot','linestyle','--'); set(zax,'user',[z,zboxh,wboxh]); set(fig,'windowbuttonmotionfcn','holo(''rectm'')'); set(fig,'windowbuttonupfcn','holo(''rectu'')'); elseif strcmp(action,'rectm') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); pt = get(fig,'currentpoint'); if pt(2)>ud.actbot set(fig,'pointer','crosshair'); zax = ud.zaxes; u = get(zax,'user'); z1 = u(1); zboxh = u(2); wboxh = u(3); wh = ud.wh; point = get(zax,'currentpoint'); point = point(1,[1,2]); z2 = point(1)+i*point(2); x = real([z1,z1,z2,z2,z1]); y = imag([z1,z2,z2,z1,z1]); set(zboxh,'xdata',x,'ydata',y); zz = z1 + (z2 - z1)*linspace(0,1); x1 = real(zz); x = [real(z1)*ones(1,100),x1,real(z2)*ones(1,100),fliplr(x1)]; y1 = imag(zz); y = [y1,imag(z2)*ones(1,100),fliplr(y1),imag(z1)*ones(1,100)]; z = x+i*y; FFF = ud.fcn; w = eval(FFF); set(wboxh,'xdata',real(w),'ydata',imag(w)); z=z2;w=eval(FFF); set(wh,'xdata',real(w),'ydata',imag(w)); else set(fig,'pointer','arrow') end elseif strcmp(action,'rectu') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); zax = ud.zaxes; u = get(zax,'user'); z1 = u(1); delete(u(2:3)); point = get(zax,'currentpoint'); point = point(1,[1,2]); z2 = point(1)+i*point(2); plotrectgrid(z1,z2,fig) set(fig,'windowbuttonmotionfcn','holo(''pointm'')',... 'windowbuttonupfcn',''); set(findobj(zax),'buttondownfcn','holo(''rect'')'); elseif strcmp(action,'polar') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(gcf,'user'); zax = ud.zaxes; wax = ud.waxes; point = get(zax,'currentpoint'); point = point(1,[1,2]); z = point(1)+i*point(2); plot(real(z),imag(z),'o',... 'parent',zax,'tag','holoplot'); circh = plot(real(z),imag(z),... 'erasemode','xor','parent',zax,... 'tag','holoplot'); w = eval(ud.fcn); wlineh = plot(real(w),imag(w),... 'erase','xor','parent',wax,... 'tag','holoplot'); set(zax,'user',[z,circh,wlineh]); set(gcf,'windowbuttonmotionfcn','holo(''circlem'')',... 'windowbuttonupfcn','holo(''polaru'')'); elseif strcmp(action,'polarm') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); pt = get(fig,'currentpoint'); if pt(2)>ud.actbot set(fig,'pointer','crosshair'); zax = ud.zaxes; u = get(gca,'user'); center = u(1); circh = u(2); wlineh = u(3); point = get(zax,'currentpoint'); point = point(1,[1,2]); z2 = point(1)+i*point(2); radius = abs(center - z2); ang = exp(i*pi*(-1:(2/100):1)); z = cent+radius*ang; set(circh,'xdata',real(z),'ydata',imag(z)); % axes(ud.waxes); FFF = get(ud.fcns,'user'); l = length(z); zz1 = z(1:l-1);zz2=z(2:l); N = find((real(zz1)<=0)); y1 = (imag(zz1(N))>=0); y2 = (imag(zz2(N))>=0); M = find(y1-y2); z(N(M))=NaN*ones(size(M)); w = eval(FFF); set(wlineh,'xdata',real(w),'ydata',imag(w),'linestyle','--'); z=z1;w=eval(FFF); set(wh,'xdata',real(w),'ydata',imag(w)); % axes(ud.zaxes); else set(fig,'pointer','arrow') end elseif strcmp(action,'polaru') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); zax = ud.zaxes; wax = ud.waxes; FFF = ud.fcn; u = get(zax,'user'); center = u(1); delete(u(2:3)); point = get(zax,'currentpoint'); point = point(1,[1,2]); z2 = point(1)+i*point(2); radius = abs(z2-center); plotradgrid(center,radius,fig) set(fig,'windowbuttonmotionfcn','holo(''pointm'')',... 'windowbuttonupfcn',''); set(findobj(zax),'buttondownfcn','holo(''polar'')'); elseif strcmp(action,'rectmap') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); prompt ={'Enter the lower left corner of the rectangle','Enter the upper right corner of the rectangle'}; title2 = 'Input for a rectangle to be mapped.'; answer = inputdlg(prompt,title2); if isempty(answer) return end if isempty(answer{1}) errordlg('No lower left corner was provided.'); return elseif isempty(answer{2}) errordlg('No upper right corner was provided.'); return end z1 = str2num(answer{1}); z2 = str2num(answer{2}); plotrectgrid(z1,z2,fig); elseif strcmp(action,'polarmap') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); prompt ={'Enter the center of the disk','Enter the radius of the disk'}; title2 = 'Input for a disk to be mapped.'; answer = inputdlg(prompt,title2); if isempty(answer) return end if isempty(answer{1}) errordlg('No center was provided.'); return elseif isempty(answer{2}) errordlg('No radius was provided.'); return end z = str2num(answer{1}); r = str2num(answer{2}); plotradgrid(z,r,fig); elseif strcmp(action,'zchange') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); zax = ud.zaxes; prompt ={'Enter the lower left point','Enter the real increment'}; title2 = 'Input to change the z-axes'; answer = inputdlg(prompt,title2); if isempty(answer) return end if isempty(answer{1}) errordlg('No lower left point was provided.'); return elseif isempty(answer{2}) errordlg('No real increment was provided.'); return end z = str2num(answer{1}); h = str2num(answer{2}); x = real(z); y = imag(z); xlim = [x, x+h]; ylim = [y, y+h]; set(zax,'xlim',xlim,'ylim',ylim); elseif strcmp(action,'wchange') fig = findobj(get(0,'children'),'flat','name','Holomorphic Map'); ud = get(fig,'user'); wax = ud.waxes; prompt ={'Enter the lower left point','Enter the real increment'}; title2= 'Input to change the w-axes'; answer = inputdlg(prompt,title2); if isempty(answer) return end if isempty(answer{1}) errordlg('No lower left point was provided.'); return elseif isempty(answer{2}) errordlg('No real increment was provided.'); return end z = str2num(answer{1}); h = str2num(answer{2}); x = real(z); y = imag(z); xlim = [x, x+h]; ylim = [y, y+h]; set(wax,'xlim',xlim,'ylim',ylim); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function plotradgrid(z1,r,fig) ud = get(fig,'user'); zax = ud.zaxes; wax = ud.waxes; FFF = ud.fcn; radius = r; center = z1; N=8; M=6; angles = exp(i*pi*((-1+2/N):(2/N):1)); ang = exp(i*pi*(-1:(2/100):1)); radi = radius*(0:(1/(M-1)):1); rad = radius*(0:(1/100):1); circles = center+radi'*ang; z = circles.'; plot(real(z),imag(z),... 'parent',zax,'tag','holoplot'); w = eval(FFF); plot(real(w),imag(w),... 'parent',wax,'tag','holoplot'); radii = center+angles.'*rad; z = radii.'; plot(real(z),imag(z),... 'parent',zax,'tag','holoplot'); w = eval(FFF); plot(real(w),imag(w),... 'parent',wax,'tag','holoplot'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function plotrectgrid(z1,z2,fig) N = 7; ud = get(fig,'user'); zz = z1 + (z2-z1)*linspace(0,1,N); x = real(zz); y = imag(zz); x = x'*ones(1,100); zzz = z1 + (z2 - z1)*linspace(0,1); xxy = ones(N,1)*imag(zzz); %linspace(imag(z1),imag(z2)); xz = x+i*xxy; y = y'*ones(1,100); xyy = ones(N,1)*real(zzz); %linspace(real(z1),real(z2)); yz = xyy+i*y; z = [xz.',yz.']; plot(real(z),imag(z),... 'parent',ud.zaxes,'tag','holoplot'); FFF = ud.fcn; w = eval(FFF); plot(real(w),imag(w),... 'parent',ud.waxes,'tag','holoplot'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%