% SUpDEq - Spatial Upsampling by Directional Equalization function d = supdeq_haversine(AzEl1, AzEl2, radius) This function calculates the great circle distance between two points on a sphere by applying the inverse haversine function Output: d - Great circle distance d between two points on the sphere Input: AzEl1 / AzEl2 - Spatial sampling point (e.g., [0,90]), where the first value is the azimuth and the second the elevation (both in degree). Azimuth in degree (0=front, 90=left, 180=back, 270=right) (0 points to positive x-axis, 90 to positive y-axis) Elevations in degree (0=North Pole, 90=front, 180=South Pole) (0 points to positive z-axis, 180 to negative z-axis) radius - Head/Sphere radius in m Default: 0.0875 m Dependencies: - (C) 2020 by JMA, Johannes M. Arend TH Köln - University of Applied Sciences Institute of Communications Engineering Department of Acoustics and Audio Signal Processing
0001 %% SUpDEq - Spatial Upsampling by Directional Equalization 0002 % 0003 % function d = supdeq_haversine(AzEl1, AzEl2, radius) 0004 % 0005 % This function calculates the great circle distance between two points on 0006 % a sphere by applying the inverse haversine function 0007 % 0008 % Output: 0009 % d - Great circle distance d between two points on the sphere 0010 % 0011 % Input: 0012 % AzEl1 / AzEl2 - Spatial sampling point (e.g., [0,90]), where the first 0013 % value is the azimuth and the second the elevation (both in degree). 0014 % Azimuth in degree (0=front, 90=left, 180=back, 270=right) 0015 % (0 points to positive x-axis, 90 to positive y-axis) 0016 % Elevations in degree (0=North Pole, 90=front, 180=South Pole) 0017 % (0 points to positive z-axis, 180 to negative z-axis) 0018 % radius - Head/Sphere radius in m 0019 % Default: 0.0875 m 0020 % 0021 % Dependencies: - 0022 % 0023 % (C) 2020 by JMA, Johannes M. Arend 0024 % TH Köln - University of Applied Sciences 0025 % Institute of Communications Engineering 0026 % Department of Acoustics and Audio Signal Processing 0027 0028 function d = supdeq_haversine(AzEl1, AzEl2, radius) 0029 0030 if nargin < 3 || isempty(radius) 0031 radius = 0.0875; 0032 end 0033 0034 %% Transform sampling points to radiant in matlab coordinates system 0035 0036 AzEl1 = AzEl1*pi/180; 0037 AzEl1(:,2) = pi/2 - AzEl1(:,2); 0038 0039 AzEl2 = AzEl2*pi/180; 0040 AzEl2(:,2) = pi/2 - AzEl2(:,2); 0041 0042 %% Apply formula 0043 0044 %Get distance between angular values 0045 dAz = AzEl2(:,1) - AzEl1(:,1); 0046 dEl = AzEl2(:,2) - AzEl1(:,2); 0047 0048 %Get great circular distance 0049 d = 2 * radius * asin( sqrt( sin(dAz/2).^2 + cos(AzEl1(:,1)) .* cos(AzEl2(:,1)) .* sin(dEl/2).^2)); 0050 0051 end 0052