Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nearest-neighbour search for BRIR direction #126

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions SFS_ir/get_ir.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,21 @@
end
% Find nearest head orientation in the horizontal plane
[phi,theta] = sofa_get_head_orientations(header);
[neighbours_head,idx_head] = ...
findnearestneighbour([phi theta]',head_orientation,3);
[x(:,1),x(:,2),x(:,3)] = sph2cart(phi,theta,ones(length(phi),1));
[x_desired(1),x_desired(2),x_desired(3)] = ...
sph2cart(head_orientation(1),head_orientation(2),1);
[neighbours,idx_head] = findnearestneighbour(x',x_desired',3);
[neighbours_head(1,:),neighbours_head(2,:)] = ...
cart2sph(neighbours(1,:),neighbours(2,:),neighbours(3,:));
% Check if head orientation is out of bounds
if all(abs(head_orientation(1))>abs(neighbours_head(1,:)))
if all(abs(head_orientation(1))-abs(neighbours_head(1,:))>0.001)
warning('SFS:get_ir',['Head azimuth %.1f deg out of bound, ', ...
'using %.1f deg instead.'], ...
deg(head_orientation(1)), ...
deg(neighbours_head(1,1)));
head_orientation(1) = neighbours_head(1,1);
end
if all(abs(head_orientation(2))>abs(neighbours_head(2,:)))
if all(abs(head_orientation(2))-abs(neighbours_head(2,:))>0.001)
warning('SFS:get_ir',['Head elevation %.1f deg out of bound, ', ...
'using %.1f deg instead.'], ...
deg(head_orientation(2)), ...
Expand Down