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
\ No newline at end of file
249
\ No newline at end of file
......@@ -121,9 +121,7 @@ for i = 1:length(trajectories)
] = artoa.controller.track.trajectoryOutput.plotSoundsourceLines( ...
artoaGui.trajectoryOutput.axesTrajectoryOutput, ...
trajectories{i}, ...
artoaWorkspace.filteredSoundsources, ...
trajectoryColor, ...
pPlotAsMap ...
artoaWorkspace.filteredSoundsources...
);
% 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
% Detailed explanation goes here
%% Get all sound sources that are involved
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');
%% Initialize return variables
lineHandles = {};
for o = 1:length(involvedSoundsourceNames)
currentSoundsource = involvedSoundsources.(involvedSoundsourceNames{o});
for i = o + 1:length(involvedSoundsourceNames)
innerSoundsource = involvedSoundsources.(involvedSoundsourceNames{i});
% calculate great circle track
[latTrack, lonTrack] = track2( ...
currentSoundsource.position(1), ...
currentSoundsource.position(2), ...
innerSoundsource.position(1), ...
innerSoundsource.position(2) ...
);
if pPlotAsMap
lineHandles{end + 1} = linem(latTrack, lonTrack, 'Color', pColor);
else
lineHandles{end + 1} = line(pAxesHandle, lonTrack, latTrack, 'Color', pColor);
%% Get required variables
segmentCount = length(pTrajectory.segmentSize);
%% Get colors
trajectoryColors = jet(round(length(pTrajectory.segmentSize) * 1.5));
%% Get all combinations of involved soundsource pairs
internalCombinations = {};
internalColors = [];
for i = 1:segmentCount
currentCombination = pTrajectory.trackParameter.soundsourceCombinations.soundsources{i};
% get all soundsources separate
involvedSoundsources = strsplit(currentCombination, ' ');
for k = 1:length(involvedSoundsources)
outerSoundsource = involvedSoundsources{k};
for j = k + 1:length(involvedSoundsources)
internalCombinations{end + 1} = {outerSoundsource, involvedSoundsources{j}};
internalColors(end + 1, :) = fliplr(trajectoryColors(i, :));
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
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