ita_SOFACoordinates2ItaHRTFCoordinates.m 1.49 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
function varargout = ita_SOFACoordinates2ItaHRTFCoordinates(handleSofa)
% - +++ Short Description here +++
%  TODO: Full and logical SOFA support. This is just a test


% <ITA-Toolbox>
% This file is part of the application HRTF_class for the ITA-Toolbox. All rights reserved.
% You can find the license for this m-file in the application folder.
% </ITA-Toolbox>


% Author: Jan Gerrit Richter -- Email: jan.richter@akustik.rwth-aachen.de
% Created:  13-May-2014 


%% Initialization and Input Parsing

%% TODO: check the handle


%% main
% get the number of positions
numPositions = length(handleSofa.SourcePosition);

coordinates = itaCoordinates(numPositions);

data = handleSofa.SourcePosition;

if ~(strcmp('spherical',handleSofa.SourcePosition_Type))
   % cartesian system
    ita_verbose_info('No spherical coordinate system. Not tested');
    coordinates.x = data(:,1);
    coordinates.y = data(:,2);
    coordinates.z = data(:,3);
else
    % spherical system
    coordinates.phi_deg = data(:,1);
    coordinates.theta_deg = data(:,2)+90;
    coordinates.r = data(:,3);
end


listenerView = handleSofa.ListenerView;
if ~(length(handleSofa.ListenerView) == 3)
  ita_verbose_info('view vector dimensions are funky - There might be a problem');  
  listenerView = handleSofa.ListenerView(1,:);
end
    
if sum(listenerView == logical([1 0 0])) ~= 3
    ita_verbose_info('Non standard view vector. Not implemented - Coordinate System probably wrong');
end





%% Set Output
varargout(1) = {coordinates}; 

%end function
end