Commit 058c1848 authored by Ernesto Accolti's avatar Ernesto Accolti

+ Modified setModelToFaces method of itaRavenProject so as to point to...

+ Modified setModelToFaces method of itaRavenProject so as to point to materials in the first element of the face vector.
+ Added the posibility to plot surfaces normals in itaAc3dModel.m
+ modified ita_raven_demo_faces_room.m so as to reflect the above modifications
+ just updated documentation part of ita_time_window.m for compatibility with ita_generate_sweep.m
parent 0d44da95
......@@ -236,12 +236,18 @@ classdef itaAc3dModel
end % function readAc3DModelFile()
function plotModel(obj, axes2Plot, component2axesMapping, wireframe)
function plotModel(obj, axes2Plot, component2axesMapping, wireframe,plotnormals)
% colors = [ 1.0 0.0 0.0 0.5 0.5 0.0 0.5 0.5 1.0 1.0 0.0 0.5 0.0 0.5 1.0 0.1 0.3 0.5 0.7 0.9;
% 0.0 1.0 0.0 0.5 0.0 0.5 0.5 1.0 0.5 0.5 1.0 0.0 0.5 1.0 0.0 0.1 0.3 0.5 0.7 0.9;
% 0.0 0.0 1.0 0.0 0.5 0.5 1.0 0.5 0.5 0.0 0.5 1.0 1.0 0.5 0.5 0.1 0.3 0.5 0.7 0.9 ];
if nargin < 5
plotnormals = 0;
end
if nargin < 4
wireframe = 0;
end
......@@ -288,6 +294,22 @@ classdef itaAc3dModel
obj.nodes(polyNodes,component2axesMapping(3)) * invertAxes(3), ...
[0.5 0.5 0.5], ...
'FaceAlpha', obj.transparency );
if plotnormals
node1=[obj.nodes(polyNodes(1),component2axesMapping(1)) * invertAxes(1), ...
obj.nodes(polyNodes(1),component2axesMapping(2)) * invertAxes(2), ...
obj.nodes(polyNodes(1),component2axesMapping(3)) * invertAxes(3)];
node2=[obj.nodes(polyNodes(2),component2axesMapping(1)) * invertAxes(1), ...
obj.nodes(polyNodes(2),component2axesMapping(2)) * invertAxes(2), ...
obj.nodes(polyNodes(2),component2axesMapping(3)) * invertAxes(3)];
node3=[obj.nodes(polyNodes(3),component2axesMapping(1)) * invertAxes(1), ...
obj.nodes(polyNodes(3),component2axesMapping(2)) * invertAxes(2), ...
obj.nodes(polyNodes(3),component2axesMapping(3)) * invertAxes(3)];
normal = cross(node1 - node2, node3 - node2);
U=normal/norm(normal);
B0=mean(obj.nodes(polyNodes,component2axesMapping).*invertAxes,1);
quiver3(B0(1),B0(2),B0(3),plotnormals*U(1),plotnormals*U(2),plotnormals*U(3),3);
plot3(B0(1),B0(2),B0(3),'s');
end
end
% Plot Boundary Groups
......
......@@ -842,7 +842,7 @@ classdef itaRavenProject < handle
%------------------------------------------------------------------
function [outputFilePath] = setModelToFaces(obj,points,faces,materials)
% setModelToSArbitrary
% setModelToFaces
% creates a room model using points and faces and automatically
% sets the model of the current project to the so defined room.
% The room has one material assigned to each face (mat1 ..
......@@ -876,6 +876,16 @@ classdef itaRavenProject < handle
% the folder of the current rpf file.
outputFilePath = [ fileparts(obj.ravenProjectFile) '\' outputFileName ];
end
fn = floor(size(points,2)/4); % first element of a three elements point
if size(points,2)>3
idx = (points(:,1));
else
idx=1:size(points,1);
end
fid = fopen(outputFilePath,'w');
fprintf(fid,'AC3Db\n');
......@@ -895,7 +905,7 @@ classdef itaRavenProject < handle
fprintf(fid,['numvert ' num2str(nP) '\n']);
for iP=1:nP
fprintf(fid,[sprintf('%1.4f %1.4f %1.4f',points(faces{iW}(iP+1),:)) '\n']);
fprintf(fid,[sprintf('%1.4f %1.4f %1.4f',points(faces{iW}(iP+1)==idx,fn+(1:3))) '\n']);
end
fprintf(fid,'numsurf 1\n');
......@@ -991,7 +1001,7 @@ classdef itaRavenProject < handle
quiver3(spos(:,1),spos(:,2),spos(:,3),sview(:,1),sview(:,2),sview(:,3),0,'color','r','maxheadsize',1.5,'linewidth',1.5);
% plot view/up vectors (red) of receivers
% quiver3(rpos(:,1),rpos(:,2),rpos(:,3),rview(:,1),rview(:,2),rview(:,3),0,'color','r','maxheadsize',1.5,'linewidth',1.5);
quiver3(rpos(:,1),rpos(:,2),rpos(:,3),rview(:,1),rview(:,2),rview(:,3),0,'color','r','maxheadsize',1.5,'linewidth',1.5);
% plot up vectors (green) of sources and receivers (currently
......
......@@ -10,7 +10,7 @@
% </ITA-Toolbox>
%% project settings
projectName = 'my_6_faces';
projectName = 'my_Fan_shape';
h1=10; h2 = 4;
w1=14; w2 =24;
......@@ -47,6 +47,9 @@ for iMat=1:nM
rpf.setMaterial(rpf.getRoomMaterialNames{iMat},myAbsorp,myScatter);
end
%% Check: Plane normals should point to the inner side of the room
rpf.model.plotModel([], [1 2 3], 0,1)
axis equal
%% set simulation parameters
rpf.setGenerateRIR(1);
rpf.setGenerateBRIR(1);
......@@ -64,9 +67,9 @@ rpf.plotSphereEnergy();
RIR = rpf.getMonauralImpulseResponseItaAudio;
RIR.ptd;
T30 = rpf.getT30;
%%
figure;
semilogx(rpf.freqVectorOct,T30','LineWidth',1.5,'Marker','x');
grid on;ylabel('T30 in s');xlabel('Frequency in Hz');
title('T30 of two shoebox rooms');xlim([20 20000]);
title('T30 of a Fan shape room');xlim([20 20000]);
......@@ -25,7 +25,7 @@ function [ varargout ] = ita_time_window( varargin )
% dc (false) - dc correction after m�ller (bma)
%
% Example:
% sweep = ita_generate('expsweep',[2 22000],44100,16);
% sweep = ita_generate_sweep('freqRange',[2 22000]);
% result = ita_time_window(sweep,[2,1, 19,20],@hann,'time')
% a left sided Hamming window is applied to the sweep between 1 and
% 2 seconds. The order of the interval is 2,1 and not 1,2. This is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment