function [timeDivergence, usedIndices] = calculateTimeDivergence(pPositionSet1, pPositionSet2, pSoundVelocity)
%CALCULATETIMEDIVERGENCE Summary of this function goes here
%   Detailed explanation goes here

%% Setup variables
timeDivergence = [];
usedIndices = [];

%% Parameter check
if isempty(pPositionSet1) || isempty(pPositionSet2)
    return;
end
%% Calculate distance between sets
for i = 1:size(pPositionSet1, 1)
    if any(isnan(pPositionSet1(i, :))) || any(isnan(pPositionSet2(i, :)))
        usedIndices = [usedIndices; false];
        continue;
    end
    timeDivergence = [
        timeDivergence; ...
        artoa.data.calculateGeodist(pPositionSet1(i, :), pPositionSet2(i, :)) ...
    ];
    usedIndices = [usedIndices; true];
end

%% Divide by sound velocity
timeDivergence = timeDivergence / (pSoundVelocity/1000);
usedIndices = logical(usedIndices);

end

