added agent position trail to plot

This commit is contained in:
2026-01-01 16:06:19 -08:00
parent 4735c2b77b
commit c59b96f547
7 changed files with 61 additions and 9 deletions

View File

@@ -17,8 +17,8 @@ function [obj] = updatePlots(obj, updatePartitions)
obj.agents{ii}.updatePlots();
end
% The remaining updates might be possible to do in a clever way
% that moves existing lines instead of clearing and
% The remaining updates might should all be possible to do in a clever
% way that moves existing lines instead of clearing and
% re-plotting, which is much better for performance boost
% Update agent connections plot
@@ -41,15 +41,23 @@ function [obj] = updatePlots(obj, updatePartitions)
ylim(obj.f.Children(1).Children(obj.spatialPlotIndices(ii)), [obj.domain.minCorner(2), obj.domain.maxCorner(2)]);
zlim(obj.f.Children(1).Children(obj.spatialPlotIndices(ii)), [obj.domain.minCorner(3), obj.domain.maxCorner(3)]);
end
% Update agent trails
for ii = 1:size(obj.agents, 1)
obj.trailPlot(ii).XData(obj.timestepIndex) = obj.posHist(ii, obj.timestepIndex, 1);
obj.trailPlot(ii).YData(obj.timestepIndex) = obj.posHist(ii, obj.timestepIndex, 2);
obj.trailPlot(ii).ZData(obj.timestepIndex) = obj.posHist(ii, obj.timestepIndex, 3);
end
drawnow;
% Update performance plot
% Re-normalize performance plot
normalizingFactor = 1/max(obj.performance(end));
obj.performancePlot(1).YData(1:length(obj.performance)) = obj.performance * normalizingFactor;
obj.performancePlot(1).XData(find(isnan(obj.performancePlot(1).XData), 1, 'first')) = obj.t;
obj.performancePlot(1).XData(obj.timestepIndex) = obj.t;
for ii = 2:(size(obj.agents, 1) + 1)
obj.performancePlot(ii).YData(1:length(obj.performance)) = obj.agents{ii - 1}.performance * normalizingFactor;
obj.performancePlot(ii).XData(find(isnan(obj.performancePlot(ii).XData), 1, 'first')) = obj.t;
obj.performancePlot(ii).XData(obj.timestepIndex) = obj.t;
end
end