From 2bdbb0aed002894642e8c93ca5670411b5b203ca Mon Sep 17 00:00:00 2001 From: VeraE Date: Thu, 5 Jan 2017 18:26:04 +0100 Subject: [PATCH 1/2] correct nearest neighbour search for BRIR direction --- SFS_ir/get_ir.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SFS_ir/get_ir.m b/SFS_ir/get_ir.m index 75f7a838..fe7aeef9 100644 --- a/SFS_ir/get_ir.m +++ b/SFS_ir/get_ir.m @@ -166,8 +166,12 @@ 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,:))) warning('SFS:get_ir',['Head azimuth %.1f deg out of bound, ', ... From 8f430814699f1db8d11ec2ec898cdc7930e9937a Mon Sep 17 00:00:00 2001 From: VeraE Date: Thu, 5 Jan 2017 18:33:29 +0100 Subject: [PATCH 2/2] prevent warning due to numerical inaccuracies --- SFS_ir/get_ir.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SFS_ir/get_ir.m b/SFS_ir/get_ir.m index fe7aeef9..b377d8f5 100644 --- a/SFS_ir/get_ir.m +++ b/SFS_ir/get_ir.m @@ -173,14 +173,14 @@ [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)), ...