Commit 89231f44 authored by henryjandrew's avatar henryjandrew
Browse files

updated example__ppa work in progress

parent aa8509fe
...@@ -184,13 +184,13 @@ function [frequency_mags, gain, delay] = ita_get_propagation_path_data( path_str ...@@ -184,13 +184,13 @@ function [frequency_mags, gain, delay] = ita_get_propagation_path_data( path_str
frequency_mags = ones(1,length(f)); frequency_mags = ones(1,length(f));
total_distance = 0; total_distance = 0;
is_diff = 0; %set to 1 whenever a diffraction is encountered is_diff = 0; %set to 1 whenever a diffraction is encountered
%{
figure figure
for i = 1:numel(path_data)-1 for i = 1:numel(path_data)-1
plot3([path_data{i}.interaction_point(1),path_data{i+1}.interaction_point(1)],[path_data{i}.interaction_point(2),path_data{i+1}.interaction_point(2)],[path_data{i}.interaction_point(3),path_data{i+1}.interaction_point(3)]) plot3([path_data{i}.interaction_point(1),path_data{i+1}.interaction_point(1)],[path_data{i}.interaction_point(2),path_data{i+1}.interaction_point(2)],[path_data{i}.interaction_point(3),path_data{i+1}.interaction_point(3)])
hold on hold on
end end
%}
for i = 2:numel(path_data)-1 %start from 2, first entry is always source, -1 as receiver always the last for i = 2:numel(path_data)-1 %start from 2, first entry is always source, -1 as receiver always the last
anchor_type = path_data{i}.anchor_type; anchor_type = path_data{i}.anchor_type;
segment_distance = norm(path_data{ i }.interaction_point(1:3) - path_data{ i-1 }.interaction_point(1:3)); segment_distance = norm(path_data{ i }.interaction_point(1:3) - path_data{ i-1 }.interaction_point(1:3));
...@@ -204,23 +204,22 @@ function [frequency_mags, gain, delay] = ita_get_propagation_path_data( path_str ...@@ -204,23 +204,22 @@ function [frequency_mags, gain, delay] = ita_get_propagation_path_data( path_str
vertex_length = norm( path_data{i}.vertex_start(1:3) - path_data{i}.vertex_end(1:3) ); vertex_length = norm( path_data{i}.vertex_start(1:3) - path_data{i}.vertex_end(1:3) );
%wedge_type = path_struct{i}.anchor_type; %FOR NOW ALWAYS USE THE DEFAULT WEDGE TYPE %wedge_type = path_struct{i}.anchor_type; %FOR NOW ALWAYS USE THE DEFAULT WEDGE TYPE
w = itaFiniteWedge( main_face_normal, opposite_face_normal, aperture_start, vertex_length ); w = itaFiniteWedge( main_face_normal, opposite_face_normal, aperture_start, vertex_length, 'wedge' );
w.set_get_geo_eps( 1e-6 );
source_pos = path_data{i-1}.interaction_point(1:3); source_pos = path_data{i-1}.interaction_point(1:3);
receiver_pos = path_data{i+1}.interaction_point(1:3); receiver_pos = path_data{i+1}.interaction_point(1:3);
rho = ita_propagation_effective_source_distance( path_struct, i ); %effective distance from aperture point to source rho = ita_propagation_effective_source_distance( path_struct, i ); %effective distance from aperture point to source
source_dist = rho;
last_pos_dirn = path_data{i-1}.interaction_point(1:3) - path_data{i}.interaction_point(1:3); %direction to the last source last_pos_dirn = path_data{i-1}.interaction_point(1:3) - path_data{i}.interaction_point(1:3); %direction to the last source
eff_source_pos = ( last_pos_dirn .* source_dist ./ norm(last_pos_dirn) ) + path_data{i}.interaction_point(1:3); eff_source_pos = ( last_pos_dirn .* rho ./ norm(last_pos_dirn) ) + path_data{i}.interaction_point(1:3);
r = ita_propagation_effective_target_distance( path_struct, i ); %effective distance from aperture point to receiver r = ita_propagation_effective_target_distance( path_struct, i ); %effective distance from aperture point to receiver
target_dist= r;
next_pos_dirn = path_data{i+1}.interaction_point(1:3) - path_data{i}.interaction_point(1:3); %"receiver" next_pos_dirn = path_data{i+1}.interaction_point(1:3) - path_data{i}.interaction_point(1:3); %"receiver"
eff_receiver_pos = ( next_pos_dirn .* target_dist ./ norm(next_pos_dirn) ) + path_data{i}.interaction_point(1:3); eff_receiver_pos = ( next_pos_dirn .* r ./ norm(next_pos_dirn) ) + path_data{i}.interaction_point(1:3);
%{
plot3([w.aperture_start_point(1),w.aperture_end_point(1)],[w.aperture_start_point(2),w.aperture_end_point(2)],[w.aperture_start_point(3),w.aperture_end_point(3)]) plot3([w.aperture_start_point(1),w.aperture_end_point(1)],[w.aperture_start_point(2),w.aperture_end_point(2)],[w.aperture_start_point(3),w.aperture_end_point(3)])
plot3([eff_source_pos(1),path_data{i}.interaction_point(1)],[eff_source_pos(2),path_data{i}.interaction_point(2)],[eff_source_pos(3),path_data{i}.interaction_point(3)]) plot3([eff_source_pos(1),path_data{i}.interaction_point(1)],[eff_source_pos(2),path_data{i}.interaction_point(2)],[eff_source_pos(3),path_data{i}.interaction_point(3)])
plot3([eff_receiver_pos(1),path_data{i}.interaction_point(1)],[eff_receiver_pos(2),path_data{i}.interaction_point(2)],[eff_receiver_pos(3),path_data{i}.interaction_point(3)]) plot3([eff_receiver_pos(1),path_data{i}.interaction_point(1)],[eff_receiver_pos(2),path_data{i}.interaction_point(2)],[eff_receiver_pos(3),path_data{i}.interaction_point(3)])
%}
%{ %{
smallest_dist = 1000000; smallest_dist = 1000000;
n0 = 10000; %number of iterations n0 = 10000; %number of iterations
...@@ -236,46 +235,59 @@ function [frequency_mags, gain, delay] = ita_get_propagation_path_data( path_str ...@@ -236,46 +235,59 @@ function [frequency_mags, gain, delay] = ita_get_propagation_path_data( path_str
end end
end end
plot3(ap_point(1),ap_point(2),ap_point(3),'.k') %true closest point plot3(ap_point(1),ap_point(2),ap_point(3),'.k') %true closest point
%}
ap_point2 = w.get_aperture_point( source_pos, receiver_pos ); ap_point2 = w.get_aperture_point( source_pos, receiver_pos );
ap_point3 = w.get_aperture_point( eff_source_pos, eff_receiver_pos ); ap_point3 = w.get_aperture_point( eff_source_pos, eff_receiver_pos );
ap_point4 = w.get_aperture_point2( source_pos, receiver_pos ); ap_point4 = w.get_aperture_point2( source_pos, receiver_pos );
plot3(ap_point2(1),ap_point2(2),ap_point2(3),'.r') %point which should be predicted from aperture point method plot3(ap_point2(1),ap_point2(2),ap_point2(3),'.r') %point which should be predicted from aperture point method
plot3(ap_point3(1),ap_point3(2),ap_point3(3),'.b') %point which should be predicted from aperture point method plot3(ap_point3(1),ap_point3(2),ap_point3(3),'.b') %point which should be predicted from aperture point method
plot3(ap_point4(1),ap_point4(2),ap_point4(3),'.g') %point which should be predicted from aperture point method plot3(ap_point4(1),ap_point4(2),ap_point4(3),'.g') %point which should be predicted from aperture point method
%}
aperture_point = w.get_aperture_point2( source_pos, receiver_pos );
[~, D, ~] = ita_diffraction_utd( w, source_pos, receiver_pos, f, c ); if( w.point_on_aperture( aperture_point ) == 0 )
warning('Skipping path, aperture point calculated not on the aperture');
A = sqrt( rho ./ ( r .* ( rho + r ) ) ); % attenuation factor at receiver continue
end
[~, D, A] = ita_diffraction_utd( w, eff_source_pos, eff_receiver_pos, f, c, aperture_point );
if( is_diff == 0 ) if( is_diff == 0 )
gain = gain * (A / source_dist); gain = gain * (A / rho);
is_diff = 1; is_diff = 1;
else else
gain = gain * A; gain = gain * A;
end end
frequency_mags = frequency_mags .* abs(D); frequency_mags = frequency_mags .* abs(D);
case 'inner_edge_diffraction' case 'inner_edge_diffraction'
source_pos = path_data{i-1}.interaction_point(1:3);
receiver_pos = path_data{i+1}.interaction_point(1:3);
opposite_face_normal = path_data{i}.main_wedge_face_normal(1:3); opposite_face_normal = path_data{i}.main_wedge_face_normal(1:3);
main_face_normal = path_data{i}.opposite_wedge_face_normal(1:3); main_face_normal = path_data{i}.opposite_wedge_face_normal(1:3);
aperture_start = path_data{i}.vertex_start(1:3); %aperture point aperture_start = path_data{i}.vertex_start(1:3); %aperture point
vertex_length = norm( path_data{i}.vertex_start(1:3) - path_data{i}.vertex_end(1:3) ); vertex_length = norm( path_data{i}.vertex_start(1:3) - path_data{i}.vertex_end(1:3) );
%wedge_type = path_struct{i}.anchor_type; %FOR NOW ALWAYS USE THE DEFAULT WEDGE TYPE %wedge_type = path_struct{i}.anchor_type; %FOR NOW ALWAYS USE THE DEFAULT WEDGE TYPE
w = itaFiniteWedge( main_face_normal, opposite_face_normal, aperture_start, vertex_length ); w = itaFiniteWedge( main_face_normal, opposite_face_normal, aperture_start, vertex_length, 'corner' );
w.set_get_geo_eps( 1e-6 );
rho = ita_propagation_effective_source_distance( path_struct, i ); %effective distance from aperture point to source rho = ita_propagation_effective_source_distance( path_struct, i ); %effective distance from aperture point to source
source_dist = rho; last_pos_dirn = path_data{i-1}.interaction_point(1:3) - path_data{i}.interaction_point(1:3); %direction to the last source
eff_source_pos = ( last_pos_dirn .* rho ./ norm(last_pos_dirn) ) + path_data{i}.interaction_point(1:3);
r = ita_propagation_effective_target_distance( path_struct, i ); %effective distance from aperture point to receiver r = ita_propagation_effective_target_distance( path_struct, i ); %effective distance from aperture point to receiver
target_dist= r; next_pos_dirn = path_data{i+1}.interaction_point(1:3) - path_data{i}.interaction_point(1:3); %"receiver"
eff_receiver_pos = ( next_pos_dirn .* r ./ norm(next_pos_dirn) ) + path_data{i}.interaction_point(1:3);
[~, D, ~] = ita_diffraction_utd( w, source_pos, receiver_pos, f, c );
aperture_point = w.get_aperture_point2( source_pos, receiver_pos );
A = sqrt( rho ./ ( r .* ( rho + r ) ) ); % attenuation factor at receiver if( w.point_on_aperture( aperture_point ) == 0 )
warning('Skipping path, aperture point calculated not on the aperture');
continue
end
[~, D, A] = ita_diffraction_utd( w, eff_source_pos, eff_receiver_pos, f, c, aperture_point );
if( is_diff == 0 ) if( is_diff == 0 )
gain = gain * (A / source_dist); gain = gain * (A / rho);
is_diff = 1; is_diff = 1;
else else
gain = gain * A; gain = gain * A;
......
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