Commit 12596270 authored by henryjandrew's avatar henryjandrew
Browse files

test

parent 4f7464fd
%% Input conditions
target_path = 'path_03eff9730b428fe4b136ffe27c6684a3'; %path to follow through simulation
%target_path = 'diffracted_path';
%target_path = 'path_50df740f16865a987b4b69ff1bb12c2f';
input_folder = 'example_ppa_out';
plot_single_path_freq = true;
out_filename = 'Path_evolution.gif';
plot_single_path_freq = false;
plot_single_path = true;
plot_all_delay_changes = true;
plot_all_gain_changes = true;
plot_all_delay_changes = false;
plot_all_gain_changes = false;
load(strcat(input_folder,'\example_ppa_output_data.mat'),'-mat');
%load('example_outdoor_acoustics_output_data','-mat');
......@@ -21,7 +21,7 @@ if plot_single_path_freq
valid_evolution = zeros(N_frames,31);
end
if plot_single_path
path_data = cell(1, N_paths);
path_data = cell(1, N_frames);
end
if plot_all_delay_changes
delay_changes = zeros(N_frames, N_paths);
......@@ -45,6 +45,7 @@ for n = 1:N_frames %loop over all frames
valid_evolution(n,:) = path.audible;
path_data{n} = all_paths_data.(target_path);
N_interaction_points = size(path_data{n},1);
catch
freq_evolution(n,:) = zeros(1,31);
valid_evolution(n,:) = zeros(1,31);
......@@ -70,13 +71,11 @@ for n = 1:N_frames %loop over all frames
end
end
%fprintf( 'Took %.2f seconds for fram %i%/i%\n', toc, n, N_frames )
end
%% Plot Graphs
if plot_single_path
visualise_single_path( path_data );
visualise_single_path( path_data, out_filename, N_interaction_points );
end
if plot_single_path_freq
single_path_freq_evolution( f, N_frames, freq_evolution, valid_evolution );
......@@ -127,8 +126,87 @@ function all_path_gain_changes( gain_changes, N_paths, N_frames )
grid off
end
function visualise_single_path( path_data )
figure
function visualise_single_path( path_data, out_filename, N_interaction_points )
%% Export giff of selected path
f = figure;
a = axes;
axis equal;
plot3([-5.1251,-5.1251],[-46.6484,53.5954],[20.8399,20.8399],'-k')
hold on
plot3([-12.6201,-12.6201],[-46.6484,53.5954],[28.2501,28.2501],'-k')
plot3([-5.1251,-5.1251],[-46.6484,53.5954],[-0.1337,-0.1337],'-k')
plot3([-5.1251,-5.1251],[-46.6484,-46.6484],[-0.1337,20.8399],'-k')
plot3([-5.1251,-5.1251],[53.5954,53.5954],[-0.1337,20.8399],'-k')
plot3([6.8749,6.8749],[-46.6484,-46.6484],[-0.1337,19.7963],'-k')
plot3([6.8749,6.8749],[-46.6484,-5.6111],[19.7963,19.7963],'-k')
plot3([6.8749,6.8749],[-5.6111,-5.6111],[19.7963,-0.1337],'-k')
plot3([6.8749,80.3522],[-5.6111,-5.6111],[-0.1337,-0.1337],'-k')
plot3([80.3522,80.3522],[-5.6111,-5.6111],[-0.1337,19.7963],'-k')
plot3([80.3522,6.8749],[-5.6111,-5.6111],[19.7963,19.7963],'-k')
plot3([6.8749,6.8749],[6.3889,6.3889],[19.7963,-0.1337],'-k')
plot3([6.8749,6.8749],[6.3889,53.5954],[19.7963,19.7963],'-k')
plot3([6.8749,80.3522],[6.3889,6.3889],[19.7963,19.7963],'-k')
plot3([80.3522,80.3522],[6.3889,6.3889],[19.7963,-0.1337],'-k')
plot3([80.3522,6.8749],[6.3889,6.3889],[-0.1337,-0.1337],'-k')
plot3([6.8749,6.8749],[-46.6484,-5.6111],[-0.1337,-0.1337],'-k')
plot3([6.8749,6.8749],[6.3889,53.5954],[-0.1337,-0.1337],'-k')
plot3([6.8749,6.8749],[53.5954,53.5954],[-0.1337,19.7963],'-k')
plot3([-5.1251,-12.6201],[53.5954,53.5954],[20.8399,28.2501],'-k')
plot3([-5.1251,-12.6201],[-46.6484,-46.6484],[20.8399,28.2501],'-k')
a.XLim = [-10 20];
a.YLim = [-60 20];
a.ZLim = [-0.1337 20.8399];
axis off;
N_frames = numel(path_data);
try
source_point = plot3(path_data{1}(1,1),path_data{1}(1,2),path_data{1}(1,3),'.r');
receiver_point = plot3(path_data{1}(N_interaction_points,1),path_data{1}(N_interaction_points,2),path_data{1}(N_interaction_points,3),'.g');
catch
source_point = plot3(-1000,-1000,-1000,'.r', 'MarkerSize', 20);
receiver_point = plot3(-1000,-1000,-1000,'.g', 'MarkerSize', 20);
end
for i = 1:N_interaction_points-1
try
pointA = path_data{1}(i,:);
pointB = path_data{1}(i+1,:);
segment{i} = plot3(a, [pointA(1),pointB(1)], [pointA(2),pointB(2)], [pointA(3),pointB(3)] );
catch
segment{i} = plot3([-12.6201,-12.6201],[-46.6484,-46.6484],[28.2501,28.2501],'-b');
end
end
drawnow
frame = getframe(f);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite( imind, cm, out_filename, 'gif', 'Loopcount', inf, 'DelayTime', 0.03 );
path_start = false;
for n = 2:10:N_frames
try
source_point.XData = path_data{n}(1,1);
source_point.YData = path_data{n}(1,2);
source_point.ZData = path_data{n}(1,3);
receiver_point.XData = path_data{n}(N_interaction_points,1);
receiver_point.YData = path_data{n}(N_interaction_points,2);
receiver_point.ZData = path_data{n}(N_interaction_points,3);
for i = 1:N_interaction_points-1
segment{i}.XData = [path_data{n}(i,1), path_data{n}(i+1,1)]; % re set the x/y/z data
segment{i}.YData = [path_data{n}(i,2), path_data{n}(i+1,2)];
segment{i}.ZData = [path_data{n}(i,3), path_data{n}(i+1,3)];
path_start = true;
end
drawnow
frame = getframe(f);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
imwrite( imind, cm, out_filename, 'gif', 'WriteMode', 'append', 'DelayTime', 0.03 );
catch
if path_start
return
end
end
end
end
\ No newline at end of file
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