Skip to content
Snippets Groups Projects
Commit 45715993 authored by leprob001's avatar leprob001
Browse files

Soundsource lines are now plotted in colors of the segments.

parent 0e4e9343
No related branches found
No related tags found
No related merge requests found
248 249
\ No newline at end of file \ No newline at end of file
...@@ -121,9 +121,7 @@ for i = 1:length(trajectories) ...@@ -121,9 +121,7 @@ for i = 1:length(trajectories)
] = artoa.controller.track.trajectoryOutput.plotSoundsourceLines( ... ] = artoa.controller.track.trajectoryOutput.plotSoundsourceLines( ...
artoaGui.trajectoryOutput.axesTrajectoryOutput, ... artoaGui.trajectoryOutput.axesTrajectoryOutput, ...
trajectories{i}, ... trajectories{i}, ...
artoaWorkspace.filteredSoundsources, ... artoaWorkspace.filteredSoundsources...
trajectoryColor, ...
pPlotAsMap ...
); );
% hide lines between soundsources % hide lines between soundsources
......
function [lineHandles] = plotSoundsourceLines(pAxesHandle, pTrajectory, pSoundsources, pColor, pPlotAsMap) function [lineHandles] = plotSoundsourceLines(pAxesHandle, pTrajectory, pSoundsources)
%PLOTSOUNDSOURCELINES Summary of this function goes here %PLOTSOUNDSOURCELINES Summary of this function goes here
% Detailed explanation goes here % Detailed explanation goes here
%% Get all sound sources that are involved %% Initialize return variables
involvedSoundsourceNames = ...
unique(flatten( ...
cellfun( ...
@strsplit, pTrajectory.trackParameter.soundsourceCombinations.soundsources, 'UniformOutput', false ...
) ...
));
involvedSoundsources = artoa.soundsources.extract( ...
involvedSoundsourceNames, ...
pSoundsources, ...
true ...
);
%% Plot lines between soundsources
% make handle the current axes
axes(pAxesHandle);
hold(pAxesHandle, 'on');
lineHandles = {}; lineHandles = {};
for o = 1:length(involvedSoundsourceNames) %% Get required variables
currentSoundsource = involvedSoundsources.(involvedSoundsourceNames{o}); segmentCount = length(pTrajectory.segmentSize);
for i = o + 1:length(involvedSoundsourceNames)
innerSoundsource = involvedSoundsources.(involvedSoundsourceNames{i}); %% Get colors
% calculate great circle track trajectoryColors = jet(round(length(pTrajectory.segmentSize) * 1.5));
[latTrack, lonTrack] = track2( ...
currentSoundsource.position(1), ... %% Get all combinations of involved soundsource pairs
currentSoundsource.position(2), ... internalCombinations = {};
innerSoundsource.position(1), ... internalColors = [];
innerSoundsource.position(2) ... for i = 1:segmentCount
); currentCombination = pTrajectory.trackParameter.soundsourceCombinations.soundsources{i};
if pPlotAsMap % get all soundsources separate
lineHandles{end + 1} = linem(latTrack, lonTrack, 'Color', pColor); involvedSoundsources = strsplit(currentCombination, ' ');
else for k = 1:length(involvedSoundsources)
lineHandles{end + 1} = line(pAxesHandle, lonTrack, latTrack, 'Color', pColor); outerSoundsource = involvedSoundsources{k};
for j = k + 1:length(involvedSoundsources)
internalCombinations{end + 1} = {outerSoundsource, involvedSoundsources{j}};
internalColors(end + 1, :) = fliplr(trajectoryColors(i, :));
end end
end end
end end
hold(pAxesHandle, 'off'); %% Process all combinations
processedCombinations = {};
for m = 1:length(internalCombinations)
currentCombination = internalCombinations{m};
% check if this combination has been processed already
if ~isempty(processedCombinations) ...
& any(strcmp(processedCombinations, currentCombination))
continue;
end
% add it to the processed list
processedCombinations{end + 1} = currentCombination;
% estimate how often it occurs in the trajectory
occurrenceIndices = cellfun(@checkOccurrence, internalCombinations);
occurrences = nnz(occurrenceIndices);
% calculate great circle track
[latTrack, lonTrack] = track2( ...
pSoundsources.(currentCombination{1}).position(1), ...
pSoundsources.(currentCombination{1}).position(2), ...
pSoundsources.(currentCombination{2}).position(1), ...
pSoundsources.(currentCombination{2}).position(2) ...
);
% create color matrix
c = [];
idx = find(occurrenceIndices);
for n = 1:occurrences
c = [c; repmat(internalColors(idx(n), :), ceil(size(latTrack, 1) / occurrences), 1)];
end
c = c(1:size(latTrack, 1), :);
lineHandles{end + 1} = patch( ...
pAxesHandle, ...
'XData', [lonTrack; NaN], ...
'YData', [latTrack; NaN], ...
'facevertexcdata', [c; NaN NaN NaN], ...
'edgecolor','flat' ...
);
end
%% Helper functions
function bool = checkOccurrence(x)
bool = all(strcmp(x, currentCombination));
end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment