Commit b8dbe626 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Fixing problem when plotting inner edges / room corners

parent ee4f4b5f
......@@ -11,6 +11,15 @@ d3 = norm( w.location - source_pos );
d4 = norm( w.location - target_pos );
face_scaling = max( [ d1 d2 d3 d4 ] );
% Edge type decides which direction from aperture the faces are drawn
if strcmpi( w.edge_type, 'inner_edge' )
edge_type_sign = -1;
elseif strcmpi( w.edge_type, 'outer_edge' )
edge_type_sign = 1;
else
error 'Encountered unrecognized edge type, aborting.'
end
%% Main wedge face
......@@ -23,7 +32,7 @@ else
p1 = w.location - face_scaling * w.aperture_direction;
p2 = w.location + face_scaling * w.aperture_direction;
v_aux = cross( w.main_face_normal, w.aperture_direction );
v_aux = edge_type_sign * cross( w.main_face_normal, w.aperture_direction );
p3 = v_aux * face_scaling + p2;
p4 = v_aux * face_scaling + p1;
......@@ -36,7 +45,7 @@ Z = [ p1( 3 ); p2( 3 ); p3( 3 ); p4( 3 ) ];
%% Opposite wedge face
v_aux = -cross( w.opposite_face_normal, w.aperture_direction );
v_aux = edge_type_sign * ( -1 ) * cross( w.opposite_face_normal, w.aperture_direction );
p3 = v_aux * face_scaling + p2;
p4 = v_aux * face_scaling + p1;
......@@ -46,48 +55,48 @@ Z2 = [ p1( 3 ); p2( 3 ); p3( 3 ); p4( 3 ) ];
%% Solid-part boundary
if strcmpi( w.edge_type, 'corner' ) || strcmpi( w.edge_type, 'inner_wedge' )
v_aux = cross( w.main_face_normal, w.aperture_direction );
if strcmpi( w.edge_type, 'outer_edge' )
v_aux = edge_type_sign * cross( w.main_face_normal, w.aperture_direction );
p3 = v_aux * face_scaling / 2 + p1;
v_aux = -cross( w.opposite_face_normal, w.aperture_direction );
v_aux = edge_type_sign * ( -1 ) * cross( w.opposite_face_normal, w.aperture_direction );
p4 = v_aux * face_scaling / 2 + p1;
p5 = ( -1 ) * face_scaling * ( w.main_face_normal + w.opposite_face_normal ) / 2 + p1;
X4 = [ p1( 1 ); p3( 1 ); p4( 1 ); p5( 1 ) ];
Y4 = [ p1( 2 ); p3( 2 ); p4( 2 ); p5( 2 ) ];
Z4 = [ p1( 3 ); p3( 3 ); p4( 3 ); p5( 3 ) ];
X4 = [ p1( 1 ); p3( 1 ); p4( 1 ) ];
Y4 = [ p1( 2 ); p3( 2 ); p4( 2 ) ];
Z4 = [ p1( 3 ); p3( 3 ); p4( 3 ) ];
v_aux = cross( w.main_face_normal, w.aperture_direction );
p3 = v_aux * face_scaling / 2 + p2;
v_aux = -cross( w.opposite_face_normal, w.aperture_direction );
v_aux = edge_type_sign * ( -1 ) * cross( w.opposite_face_normal, w.aperture_direction );
p4 = v_aux * face_scaling / 2 + p2;
p5 = ( -1 ) * face_scaling * ( w.main_face_normal + w.opposite_face_normal ) / 2 + p2;
X4 = [ X4, [ p2( 1 ); p3( 1 ); p4( 1 ); p5( 1 ) ] ];
Y4 = [ Y4, [ p2( 2 ); p3( 2 ); p4( 2 ); p5( 2 ) ] ];
Z4 = [ Z4, [ p2( 3 ); p3( 3 ); p4( 3 ); p5( 3 ) ] ];
else
X4 = [ X4, [ p2( 1 ); p3( 1 ); p4( 1 ) ] ];
Y4 = [ Y4, [ p2( 2 ); p3( 2 ); p4( 2 ) ] ];
Z4 = [ Z4, [ p2( 3 ); p3( 3 ); p4( 3 ) ] ];
elseif strcmpi( w.edge_type, 'inner_edge' )
v_aux = cross( w.main_face_normal, w.aperture_direction );
v_aux = edge_type_sign * cross( w.main_face_normal, w.aperture_direction );
p3 = v_aux * face_scaling / 2 + p1;
v_aux = -cross( w.opposite_face_normal, w.aperture_direction );
v_aux = edge_type_sign * ( -1 ) * cross( w.opposite_face_normal, w.aperture_direction );
p4 = v_aux * face_scaling / 2 + p1;
p5 = ( -1 ) * face_scaling / 2 * ( w.main_face_normal + w.opposite_face_normal ) / 2 + p1;
X4 = [ p1( 1 ); p3( 1 ); p4( 1 ) ];
Y4 = [ p1( 2 ); p3( 2 ); p4( 2 ) ];
Z4 = [ p1( 3 ); p3( 3 ); p4( 3 ) ];
X4 = [ p1( 1 ); p3( 1 ); p5( 1 ); p4( 1 ) ];
Y4 = [ p1( 2 ); p3( 2 ); p5( 2 ); p4( 2 ) ];
Z4 = [ p1( 3 ); p3( 3 ); p5( 3 ); p4( 3 ) ];
v_aux = cross( w.main_face_normal, w.aperture_direction );
v_aux = edge_type_sign * cross( w.main_face_normal, w.aperture_direction );
p3 = v_aux * face_scaling / 2 + p2;
v_aux = -cross( w.opposite_face_normal, w.aperture_direction );
v_aux = edge_type_sign * ( -1 ) * cross( w.opposite_face_normal, w.aperture_direction );
p4 = v_aux * face_scaling / 2 + p2;
p5 = ( -1 ) * face_scaling / 2 * ( w.main_face_normal + w.opposite_face_normal ) / 2 + p2;
X4 = [ X4, [ p2( 1 ); p3( 1 ); p4( 1 ) ] ];
Y4 = [ Y4, [ p2( 2 ); p3( 2 ); p4( 2 ) ] ];
Z4 = [ Z4, [ p2( 3 ); p3( 3 ); p4( 3 ) ] ];
X4 = [ X4, [ p2( 1 ); p3( 1 ); p5( 1 ); p4( 1 ) ] ];
Y4 = [ Y4, [ p2( 2 ); p3( 2 ); p5( 2 ); p4( 2 ) ] ];
Z4 = [ Z4, [ p2( 3 ); p3( 3 ); p5( 3 ); p4( 3 ) ] ];
end
......
......@@ -8,8 +8,10 @@ w = itaInfiniteWedge( n1 / norm( n1 ), n2 / norm( n2 ), loc );
s = [ 3.1 0 0 ];
r = [ -3.1 0 -0.1 ];
figure
ita_diffraction_visualize_scene( w, s, r )
w_inner = itaInfiniteWedge( n1 / norm( n1 ), n2 / norm( n2 ), loc, 'inner_edge' );
figure
ita_diffraction_visualize_scene( w_inner, s, r )
Supports Markdown
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