?? room.txt
字號(hào):
function [] = radit2d(arg1,arg2,arg3)
% Purpose: analyse the acoustic of rooms in 2D with the Image Theory
%
% Results: -number of first reflections
% -sound level in dB
% -polar diagram at receptor location
%
% radit2d opens a new window with a basic case (square room). You can
% interactively move source position, add or delete walls, set wall
% absorption, ... Almost all graphic objects can be changed by
% click-and-drag or by uicontextmenu.
%
% radit2d(prop) creates a new case with values set in the argument structure
% prop. For example :
% prop=[];
% prop.xwall=[0 20 20 10 0];
% prop.ywall=[-10 -10 10 15 10];
%
% Several other functions are implemented. To obtain more information, see internet
% site ltas19.meca.ulg.ac.be/radit2d or contact Luc Masset (luc.masset@ulg.ac.be)
%
%create a new case
if ~nargin,
radit2d('init');
return
end
%too much args
if nargin > 2,
error('too much arguments')
return
end
%create a new case and apply properties given in arg1 (structure variable)
if nargin == 1,
if isstruct(arg1),
init('def')
update(arg1)
return
end
end
%update current case with properties given in arg2 (structure variable)
if nargin == 2,
if isstruct(arg2) & strcmpi(arg1,'update'),
update(arg2)
return
end
end
%unknown syntax
if nargin > 1,
error('unknown syntax')
return
end
if ~ischar(arg1),
error('unknown syntax')
return
end
%select case depending on arg1
switch lower(arg1),
case 'init'
init
case 'test'
test
case 'polardiagram'
polardiagram
case 'changedblimits'
changedblimits
case 'setcursormeasure'
setcursormeasure
case 'measure'
measure
case 'changegrid'
changegrid
hidegrid
case 'zoom'
acouzoom
case 'view'
acouview
case 'expand'
expandzone
case 'reducesurfacesize'
reducesurfacesize
case 'matchroom'
ud=get(gcf,'userdata');
ud.lastaction='moveaudiencepoint';
set(gcf,'userdata',ud)
set(gcf,'windowbuttonmotionfcn','')
set(gcf,'windowbuttonupfcn','')
set(gcf,'pointer','watch')
refreshsurfaceposition
checkroomconvexity
refreshsurfacevalues
selectvalue
set(gcf,'pointer','arrow')
case 'surfaceprecision'
surfaceprecision
case 'movedrawing'
movedrawing
case 'moveaxis'
if strcmpi(get(gcf,'selectiontype'),'normal'),
set(gcf,'windowbuttonupfcn','radit2d(''refreshmax'')')
moveaxis
end
case 'refreshmax'
ud=get(gcf,'userdata');
ud.lastaction='moveaxis';
set(gcf,'userdata',ud)
set(gcf,'windowbuttonmotionfcn','')
set(gcf,'windowbuttonupfcn','')
set(gcf,'pointer','watch')
refreshcoordinates
refreshsurfaceposition
refreshimages
selectvalue
set(gcf,'pointer','arrow')
case 'movewallpoint'
if strcmpi(get(gcf,'selectiontype'),'normal'),
set(gcf,'windowbuttonupfcn','radit2d(''refreshmwp'')')
movewallpoint
end
case 'refreshmwp'
ud=get(gcf,'userdata');
ud.lastaction='movewallpoint';
set(gcf,'userdata',ud)
set(gcf,'windowbuttonmotionfcn','')
set(gcf,'windowbuttonupfcn','')
set(gcf,'pointer','watch')
checkroomconvexity
refreshimages
refreshsurfacevalues
selectvalue
saveundo
refreshwallmenu
set(gcf,'pointer','arrow')
case 'undo'
undolastchange
case 'moveaudiencepoint'
if strcmpi(get(gcf,'selectiontype'),'normal'),
set(gcf,'windowbuttonupfcn','radit2d(''refreshmap'')')
moveaudiencepoint
end
case 'refreshmap'
ud=get(gcf,'userdata');
ud.lastaction='moveaudiencepoint';
set(gcf,'userdata',ud)
set(gcf,'windowbuttonmotionfcn','')
set(gcf,'windowbuttonupfcn','')
set(gcf,'pointer','watch')
refreshsurfaceposition
checkroomconvexity
refreshsurfacevalues
selectvalue
set(gcf,'pointer','arrow')
case 'movesource'
if strcmpi(get(gcf,'selectiontype'),'normal'),
movesource
set(gcf,'windowbuttonupfcn','radit2d(''refreshmso'')')
end
case 'refreshmso'
ud=get(gcf,'userdata');
ud.lastaction='movesource';
set(gcf,'userdata',ud)
set(gcf,'windowbuttonmotionfcn','')
set(gcf,'windowbuttonupfcn','')
set(gcf,'pointer','watch')
refreshimages
refreshsurfacevalues
selectvalue
set(gcf,'pointer','arrow')
case 'movereceptor'
if strcmpi(get(gcf,'selectiontype'),'normal'),
movereceptor
set(gcf,'windowbuttonupfcn','radit2d(''refreshmre'')')
end
case 'refreshmre'
ud=get(gcf,'userdata');
ud.lastaction='movereceptor';
set(gcf,'userdata',ud)
set(gcf,'windowbuttonmotionfcn','')
set(gcf,'windowbuttonupfcn','')
selectvalue
case 'setsourceposition'
setsourceposition
case 'setreceptorposition'
setreceptorposition
case 'splitwall'
ud=get(gcf,'userdata');
ud.lastaction='splitwall';
set(gcf,'userdata',ud)
splitwall
checkroomconvexity
refreshimages
setlayer
refreshsurfacevalues
selectvalue
refreshwallmenu
case 'setactivewall'
setactivewall
case 'symmetry'
symmetry
case 'deletevertex'
deletevertex
case 'changealpha'
changealpha
refreshwallmenu
case 'changecolormap'
changecolormap
case 'changecolorlimits'
changecolorlimits
case 'select'
selectvalue
case 'print'
printcase
case 'plan'
scaleplan
case 'printpolar'
printpolar
case 'anim'
animcase
case 'scan'
scancase
case 'load'
loadcase
case 'save'
savecase
otherwise
error('unknown argument')
end
return
%=========================================================================
function [] = init(arg)
%create a new figure with basic case (4 wall room, ...)
int=1;
if nargin,
int=0;
end
%create figure
hfig=figure;
set(hfig,'Color',get(0,'defaultUicontrolBackgroundColor'))
set(hfig,'tag','acoufig')
set(hfig,'interruptible','off')
set(hfig,'colormap',jet(256))
set(hfig,'renderer','zbuffer')
set(hfig,'menubar','none')
set(hfig,'numbertitle','off')
set(hfig,'name','Room Acoustic Design with the Image theory (2D) - Benoit Beckers & Luc Masset (2002)')
ss=get(0,'screensize');
set(hfig,'position',[(ss(3)-640)/2 (ss(4)-560)/2 640 560])
set(hfig,'resize','off')
set(hfig,'DefaultUIControlFontName','default')
set(hfig,'DefaultUIControlFontSize',6)
set(hfig,'DefaultUIControlFontAngle','normal')
set(hfig,'DefaultUIControlFontWeight','light')
set(hfig,'DefaultUIControlForeGroundColor','k')
set(hfig,'DefaultUIControlInterruptible','off')
set(hfig,'DefaultUIControlBusyAction','queue')
set(hfig,'paperunits','points')
set(hfig,'paperposition',[0 0 640 560]*0.48*2)
%enter zone dimensions
if ~int,
zdi=20;
gsize=0.5;
else
prompt={'Enter drawing zone dimension in meter ([4 640]):'};
title='Zone definition';
def={'20'};
answer=inputdlg(prompt,title,1,def);
if isempty(answer),
close(gcf)
return
end
zdi=str2num(answer{1});
if isempty(zdi),
close(gcf)
return
end
end
zdi=max([4 zdi]);
zdi=min([640 zdi]);
zdi=ceil(zdi/2)*2;
zdis= [ 4 10 20 40 80 160 320 640];
gsizes=[0.1 0.25 0.5 1 2 4 8 16];
indi=find(zdis >= zdi);
gsize=gsizes(indi(1));
height=zdi;
%create colorbar
h=patch([0 1 1 0],[-0.5 -0.5 4.5 4.5],[0 0 4 4]);
set(h,'facecolor','interp')
set(h,'edgecolor','none')
set(h,'tag','acoucbpatch')
men=uicontextmenu;
set(h,'uicontextmenu',men)
item1=uimenu(men,'tag','acouuimencolor','label','color','checked','on','callback','radit2d(''changecolormap'')');
item2=uimenu(men,'tag','acouuimengray','label','gray','checked','off','callback','radit2d(''changecolormap'')');
item3=uimenu(men,'tag','acouuimenclimauto','label','CL auto','checked','on','callback','radit2d(''changecolorlimits'')','separator','on');
item4=uimenu(men,'tag','acouuimenclimman','label','CL manual','checked','off','callback','radit2d(''changecolorlimits'')');
h=gca;
set(h,'tag','acoucbaxes')
set(h,'position',[0.89 0.2 0.05 0.6])
set(h,'xtick',[])
set(h,'yaxislocation','right')
set(h,'ticklength',[0 0])
set(h,'xlim',[0 1])
set(h,'ylim',[-0.5 4.5])
set(h,'ytick',[0:4])
set(h,'box','on')
set(h,'hittest','off')
%create axes
h=axes;
set(h,'units','normalized','position',[0 0.05 0.9 0.9])
set(h,'tag','acouaxes')
set(h,'box','on')
set(h,'xtick',[])
set(h,'ytick',[])
set(h,'dataaspectratio',[1 1 1])
set(h,'xlim',[0 zdi])
set(h,'ylim',[-zdi/2 zdi/2])
set(h,'nextplot','add')
set(h,'hittest','on')
%create X and Y axes
h=plot3([-1e5 1e5],[0 0],[-2 -2],'k');
set(h,'hittest','on')
set(h,'tag','acouXaxis')
set(h,'buttondownfcn','set(gcf,''windowbuttonmotionfcn'',''radit2d(''''moveaxis'''')'')')
h=plot3([0 0],[-1e5 1e5],[-2 -2],'k');
set(h,'hittest','on')
set(h,'tag','acouYaxis')
set(h,'buttondownfcn','set(gcf,''windowbuttonmotionfcn'',''radit2d(''''moveaxis'''')'')')
%create grid
h=plot3(0,0,-2,'.k');
set(h,'tag','acougrid')
set(h,'markersize',1)
set(h,'hittest','off')
%initial room dimensions
rdi=ceil(zdi/1.5);
%create initial walls
nwall=4;
for i=1:nwall,
hw(i)=plot([0 1],[1 1],'k');
hv(i)=plot(1,1,'.k');
end
hww=[hw(4) hw(1);hw(1) hw(2);hw(2) hw(3);hw(3) hw(4)];
hvv=[hv(1) hv(2);hv(2) hv(3);hv(3) hv(4);hv(4) hv(1);];
ymid=0;
xmid=zdi/2;
x0=xmid-rdi/2;
y0=ymid-rdi/2;
x1=xmid+rdi/2;
y1=ymid+rdi/2;
xwall=[x0 x1;x1 x1;x1 x0;x0 x0];
ywall=[y0 y0;y0 y1;y1 y1;y1 y0];
ud=[];
for i=1:nwall,
set(hw(i),'buttondownfcn','radit2d(''setactivewall'')')
ud.con=hvv(i,:);
ud.alpha=0;
set(hw(i),'userdata',ud)
set(hw(i),'xdata',xwall(i,:))
set(hw(i),'ydata',ywall(i,:))
set(hw(i),'tag','acouwall')
set(hw(i),'linewidth',1)
men=uicontextmenu;
set(hw(i),'uicontextmenu',men)
men1=uimenu(men,'label','split wall','callback','radit2d(''splitwall'')');
men2=uimenu(men,'label','delete vertex','callback','radit2d(''deletevertex'')');
men3=uimenu(men,'label','symmetry','callback','radit2d(''symmetry'')');
men4=uimenu(men,'label','change absorption','userdata',hw(i),'callback','radit2d(''changealpha'')','separator','on');
men5=uimenu(men,'label','length','separator','on');
men6=uimenu(men,'label','angle');
men7=uimenu(men,'label','absorption');
ud.con=hww(i,:);
set(hv(i),'userdata',ud)
set(hv(i),'xdata',xwall(i,1))
set(hv(i),'ydata',ywall(i,1))
set(hv(i),'tag','acouwallvertex')
set(hv(i),'markersize',15)
set(hv(i),'buttondownfcn','set(gcf,''windowbuttonmotionfcn'',''radit2d(''''movewallpoint'''')'')')
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -