Skip to content

Commit

Permalink
work on hrtf interpolation, some clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMarc committed May 28, 2021
1 parent 6624668 commit 21a81dc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions slab/hrtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,9 @@ def interpolate(self, azimuth=0, elevation=0, method='nearest'):
target = self.cartesian_source_locations((azimuth, elevation, r))
# compute distances from target direction
distances = numpy.sqrt(((target - coords)**2).sum(axis=1))
idx_nearest = numpy.argmin(distances)
# numpy.argsort(distances)[:3]
# hrtf.plot_sources(numpy.argsort(distances)[:3])
# distances[idxs]
return idx_nearest, self.data[idx_nearest]
if method == 'nearest':
idx_nearest = numpy.argmin(distances)
return self.data[idx_nearest]

def cartesian_source_locations(self, coordinates=None):
"""
Expand Down Expand Up @@ -561,8 +559,7 @@ def plot_sources(self, idx=None, show=True, axis=None):
else:
if not isinstance(axis, Axes3D):
raise ValueError("Axis must be instance of Axes3D!")
else:
ax = axis
ax = axis
coords = self.cartesian_source_locations()
ax.scatter(coords[:, 0], coords[:, 1], coords[:, 2], c='b', marker='.')
ax.scatter(0, 0, 0, c='r', marker='o')
Expand Down

0 comments on commit 21a81dc

Please sign in to comment.