Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Institute of Technical Acoustics (ITA)
toolbox
Commits
70da80ef
Commit
70da80ef
authored
Jul 31, 2019
by
Dipl.-Ing. Jonas Stienen
Browse files
Adding visualization scripts for wedge and source-receiver positions
parent
e423c824
Changes
4
Hide whitespace changes
Inline
Side-by-side
applications/SoundFieldSimulation/Diffraction/@itaInfiniteWedge/get_aperture_point2.m
View file @
70da80ef
function ap = get_aperture_point2( obj, source_pos, receiver_pos )
start = obj.
aperture_start_point
;
start = obj.
location
;
dir = obj.aperture_direction;
S_on_ap = orthogonal_projection( start, dir, source_pos ); %project the source to the aperture
...
...
applications/SoundFieldSimulation/Diffraction/@itaInfiniteWedge/itaInfiniteWedge.m
View file @
70da80ef
...
...
@@ -5,7 +5,7 @@ classdef itaInfiniteWedge
n2
% 3-dim normal vector of opposite face (internal)
ad
% 3-dim aperture direction vector (internal)
l
% Internal location variable
w
t
% type of
w
edge (internal)
e
t
% type of edge (internal)
bc_hard
% Internal boundary condition (hard = true)
end
...
...
@@ -16,27 +16,28 @@ classdef itaInfiniteWedge
location
% Location of wedge (somewhere along aperture)
opening_angle
% Angle from main to opposite face in propagation medium / air (radiants)
wedge_angle
% Angle from main to opposite face in solid medium of wedge (radiants)
edge_type
% 'wedge' for opening angles > pi or 'corner' for opening angles < pi
wedge_type
% 'wedge' for opening angles > pi or 'corner' for opening angles < pi
boundary_condition
% boundary condition of the wedge faces (hard or soft)
end
methods
function
obj
=
itaInfiniteWedge
(
main_face_normal
,
opposite_face_normal
,
location
,
w
edge_type
)
function
obj
=
itaInfiniteWedge
(
main_face_normal
,
opposite_face_normal
,
location
,
edge_type
)
% Create a wedge by a main face normal and an opposite face
% normal
% main_face_normal: Main face normal (3-dim)
% opposite_face_normal: Opposite face normal (3-dim)
% location: Point on aperture which defines
% location of the wedge in 3_dim sapce
%
w
edge_type: use '
w
edge' for opening angles > pi (default) and
% '
corner
' for opening angles < pi
% edge_type:
use '
outer_
edge' for opening angles > pi (default) and
% '
inner_edge
' for opening angles < pi
% Note: 3-dim direction vectors will be normalized automatically
%
if
nargin
<
4
w
edge_type
=
'
w
edge'
;
edge_type
=
'
outer_
edge'
;
end
if
~
isequal
(
w
edge_type
,
'
w
edge'
)
&&
~
isequal
(
w
edge_type
,
'
corner
'
)
error
(
'Invalid
w
edge type. Use either
w
edge or
corner
'
)
if
~
isequal
(
edge_type
,
'
inner_
edge'
)
&&
~
isequal
(
edge_type
,
'
outer_edge
'
)
error
(
'Invalid edge type. Use either
''
inner_
edge
''
or
''
outer_edge
''
'
)
end
if
numel
(
main_face_normal
)
~=
3
error
'Main face normal has to be a 3-dim vector'
...
...
@@ -51,7 +52,7 @@ classdef itaInfiniteWedge
obj
.
n1
=
main_face_normal
;
obj
.
n2
=
opposite_face_normal
;
obj
.
l
=
location
;
obj
.
w
t
=
w
edge_type
;
obj
.
e
t
=
edge_type
;
obj
.
bc_hard
=
true
;
if
~
obj
.
validate_normals
...
...
@@ -107,9 +108,9 @@ classdef itaInfiniteWedge
function
beta
=
get
.
wedge_angle
(
obj
)
% Returns angle from main to opposite face through solid medium
% of the wedge (radiant)
if
isequal
(
obj
.
w
t
,
'
w
edge'
)
if
isequal
(
obj
.
e
t
,
'
outer_
edge'
)
s
=
1
;
elseif
isequal
(
obj
.
w
t
,
'
corner
'
)
elseif
isequal
(
obj
.
e
t
,
'
inner_edge
'
)
s
=
-
1
;
end
beta
=
pi
-
s
*
acos
(
dot
(
obj
.
main_face_normal
,
obj
.
opposite_face_normal
));
...
...
@@ -143,8 +144,13 @@ classdef itaInfiniteWedge
end
end
function
wt
=
get
.
wedge_type
(
obj
)
wt
=
obj
.
wt
;
function
et
=
get
.
wedge_type
(
obj
)
et
=
obj
.
edge_type
;
warning
(
'Function
''
wedge_type
''
is deprecated, use
''
edge_type
''
instead.'
)
end
function
et
=
get
.
edge_type
(
obj
)
et
=
obj
.
et
;
end
function
bc
=
get
.
boundary_condition
(
obj
)
...
...
applications/SoundFieldSimulation/Diffraction/ita_diffraction_visualize_scene.m
0 → 100644
View file @
70da80ef
function
ita_diffraction_visualize_scene
(
w
,
source_pos
,
target_pos
)
%% ita_diffraction_visualize_scene Visualises a source-receiver-wedge scene
%
% Example: ita_diffraction_visualize_scene( wedge, source_pos, target_pos )
%
apx
=
w
.
get_aperture_point2
(
source_pos
,
target_pos
);
d1
=
norm
(
source_pos
-
apx
);
d2
=
norm
(
target_pos
-
apx
);
d3
=
norm
(
w
.
location
-
source_pos
);
d4
=
norm
(
w
.
location
-
target_pos
);
face_scaling
=
max
(
[
d1
d2
d3
d4
]
);
%% Main wedge face
if
isa
(
w
,
'itaFiniteWedge'
)
p1
=
w
.
aperture_start_point
;
p2
=
w
.
aperture_end_point
;
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
);
p3
=
v_aux
*
face_scaling
+
p2
;
p4
=
v_aux
*
face_scaling
+
p1
;
end
X
=
[
p1
(
1
);
p2
(
1
);
p3
(
1
);
p4
(
1
)
];
Y
=
[
p1
(
2
);
p2
(
2
);
p3
(
2
);
p4
(
2
)
];
Z
=
[
p1
(
3
);
p2
(
3
);
p3
(
3
);
p4
(
3
)
];
%% Opposite wedge face
v_aux
=
-
cross
(
w
.
opposite_face_normal
,
w
.
aperture_direction
);
p3
=
v_aux
*
face_scaling
+
p2
;
p4
=
v_aux
*
face_scaling
+
p1
;
X2
=
[
p1
(
1
);
p2
(
1
);
p3
(
1
);
p4
(
1
)
];
Y2
=
[
p1
(
2
);
p2
(
2
);
p3
(
2
);
p4
(
2
)
];
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
);
p3
=
v_aux
*
face_scaling
/
2
+
p1
;
v_aux
=
-
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
)
];
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
);
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
v_aux
=
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
);
p4
=
v_aux
*
face_scaling
/
2
+
p1
;
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
);
p4
=
v_aux
*
face_scaling
/
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
)
]
];
end
%% Aperture point
X3
=
[
source_pos
(
1
);
apx
(
1
);
target_pos
(
1
)
];
Y3
=
[
source_pos
(
2
);
apx
(
2
);
target_pos
(
2
)
];
Z3
=
[
source_pos
(
3
);
apx
(
3
);
target_pos
(
3
)
];
%% Polygon 3D plot
fill3
(
X
,
Y
,
Z
,
'red'
,
X2
,
Y2
,
Z2
,
'yellow'
,
X3
,
Y3
,
Z3
,
'green'
,
X4
,
Y4
,
Z4
,
'blue'
)
end
applications/SoundFieldSimulation/Diffraction/tests/ita_diffraction_test_visualization.m
0 → 100644
View file @
70da80ef
%% Test visualization of source-receiver-wedge scene
n1
=
[
1
,
0
,
1
];
n2
=
[
-
1
,
0
,
1
];
loc
=
[
0
0
0
];
w
=
itaInfiniteWedge
(
n1
/
norm
(
n1
),
n2
/
norm
(
n2
),
loc
);
s
=
[
3.1
0
0
];
r
=
[
-
3.1
0
-
0.1
];
ita_diffraction_visualize_scene
(
w
,
s
,
r
)
w_inner
=
itaInfiniteWedge
(
n1
/
norm
(
n1
),
n2
/
norm
(
n2
),
loc
,
'inner_edge'
);
ita_diffraction_visualize_scene
(
w_inner
,
s
,
r
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment