Skip to content

Commit a7bd876

Browse files
committed
Rename sfs.util.normal() -> sfs.util.direction_vector()
1 parent e0d94fa commit a7bd876

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

examples/horizontal_plane_arrays.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
xnorm = [1, 1, 0] # normalization point for plots
1818
grid = sfs.util.xyz_grid([-2.5, 2.5], [-1.5, 2.5], 0, spacing=0.02)
1919
acenter = [0.3, 0.7, 0] # center and normal vector of array
20-
anormal = sfs.util.normal(np.radians(35), np.radians(90))
20+
anormal = sfs.util.direction_vector(np.radians(35), np.radians(90))
2121

2222
# angular frequency
2323
omega = 2 * np.pi * f
2424
# normal vector of plane wave
25-
npw = sfs.util.normal(np.radians(pw_angle), np.radians(90))
25+
npw = sfs.util.direction_vector(np.radians(pw_angle), np.radians(90))
2626

2727

2828
def compute_and_plot_soundfield(title):

examples/sound_field_synthesis.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@
2525
# angular frequency
2626
omega = 2 * np.pi * f
2727
# normal vector of plane wave
28-
npw = sfs.util.normal(np.radians(pw_angle), np.radians(90))
28+
npw = sfs.util.direction_vector(np.radians(pw_angle), np.radians(90))
2929

3030

3131
# === get secondary source positions ===
3232
#x0, n0, a0 = sfs.array.linear(N, dx, center=[-1, 0, 0])
3333
#x0, n0, a0 = sfs.array.linear_nested(N, dx, 2*dx)
3434
#x0, n0, a0 = sfs.array.linear_random(N, 0.2*dx, 5*dx)
35-
#x0, n0, a0 = sfs.array.rectangular(N, dx, N, dx, n0=sfs.util.normal(0*np.pi/4, np.pi/2))
35+
#x0, n0, a0 = sfs.array.rectangular(N, dx, N, dx, n0=sfs.util.direction_vector(0*np.pi/4, np.pi/2))
3636
#x0, n0, a0 = sfs.array.circular(N, R)
3737
x0, n0, a0 = sfs.array.load('../data/arrays/university_rostock.csv')
3838

39-
#x0, n0, a0 = sfs.array.planar(N, dx, N, dx, n0=sfs.util.normal(np.radians(0),np.radians(180)))
40-
#x0, n0, a0 = sfs.array.cube(N, dx, N, dx, N, dx, n0=sfs.util.normal(0, np.pi/2))
39+
#x0, n0, a0 = sfs.array.planar(N, dx, N, dx, n0=sfs.util.direction_vector(np.radians(0),np.radians(180)))
40+
#x0, n0, a0 = sfs.array.cube(N, dx, N, dx, N, dx, n0=sfs.util.direction_vector(0, np.pi/2))
4141

4242
#x0, n0, a0 = sfs.array.sphere_load('/Users/spors/Documents/src/SFS/data/spherical_grids/equally_spaced_points/006561points.mat', 1, center=[.5,0,0])
4343

examples/soundfigures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
omega = 2 * np.pi * f
2323

2424
# normal vector of plane wave
25-
npw = sfs.util.normal(np.radians(pw_angle[0]), np.radians(pw_angle[1]))
25+
npw = sfs.util.direction_vector(np.radians(pw_angle[0]), np.radians(pw_angle[1]))
2626

2727
# spatial grid
2828
x = sfs.util.strict_arange(-3, 3, 0.02, endpoint=True)

sfs/mono/source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def plane(omega, x0, n0, grid, c=None):
204204
:context: close-figs
205205
206206
direction = 45 # degree
207-
n0 = sfs.util.normal(np.radians(direction), np.radians(90))
207+
n0 = sfs.util.direction_vector(np.radians(direction))
208208
p_plane = sfs.mono.source.plane(omega, x0, n0, grid)
209209
sfs.plot.soundfield(p_plane, grid);
210210
plt.title("Plane wave with direction {} degree".format(direction))

sfs/util.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ def wavenumber(omega, c=None):
3636
return omega / c
3737

3838

39-
def normal(alpha, beta):
39+
def direction_vector(alpha, beta=np.pi/2):
4040
"""Compute normal vector from azimuth, colatitude."""
41-
return [np.cos(alpha) * np.sin(beta), np.sin(alpha) * np.sin(beta),
42-
np.cos(beta)]
41+
return sph2cart(alpha, beta, 1)
4342

4443

4544
def sph2cart(alpha, beta, r):

0 commit comments

Comments
 (0)