copied agent trail lines to other perspective plots

This commit is contained in:
2026-01-14 19:11:24 -08:00
parent 105d91a492
commit 9031c9206e
4 changed files with 15 additions and 11 deletions

View File

@@ -32,10 +32,8 @@ function obj = plotConnections(obj)
end end
% Copy to other plots % Copy to other plots
if size(obj.spatialPlotIndices, 2) > 1 for ii = 2:size(obj.spatialPlotIndices, 2)
for ii = 2:size(obj.spatialPlotIndices, 2) o = [o, copyobj(o(:, 1), obj.f.Children(1).Children(obj.spatialPlotIndices(ii)))];
o = [o, copyobj(o(:, 1), obj.f.Children(1).Children(obj.spatialPlotIndices(ii)))];
end
end end
obj.connectionsPlot = o; obj.connectionsPlot = o;

View File

@@ -19,8 +19,12 @@ function obj = plotTrails(obj)
hold(obj.f.Children(1).Children(obj.spatialPlotIndices(1)), 'off'); hold(obj.f.Children(1).Children(obj.spatialPlotIndices(1)), 'off');
end end
% Copy trails to other figures? % Copy to other plots
obj.trailPlot = o; for ii = 2:size(obj.spatialPlotIndices, 2)
o = [o, copyobj(o(:, 1), obj.f.Children(1).Children(obj.spatialPlotIndices(ii)))];
end
% Add legend? % Add legend?
obj.trailPlot = o;
end end

View File

@@ -40,10 +40,12 @@ function [obj] = updatePlots(obj)
end end
% Update agent trails % Update agent trails
for ii = 1:size(obj.agents, 1) for jj = 1:size(obj.spatialPlotIndices, 2)
obj.trailPlot(ii).XData(obj.timestepIndex) = obj.posHist(ii, obj.timestepIndex, 1); for ii = 1:size(obj.agents, 1)
obj.trailPlot(ii).YData(obj.timestepIndex) = obj.posHist(ii, obj.timestepIndex, 2); obj.trailPlot((jj - 1) * size(obj.agents, 1) + ii).XData(obj.timestepIndex) = obj.posHist(ii, obj.timestepIndex, 1);
obj.trailPlot(ii).ZData(obj.timestepIndex) = obj.posHist(ii, obj.timestepIndex, 3); obj.trailPlot((jj - 1) * size(obj.agents, 1) + ii).YData(obj.timestepIndex) = obj.posHist(ii, obj.timestepIndex, 2);
obj.trailPlot((jj - 1) * size(obj.agents, 1) + ii).ZData(obj.timestepIndex) = obj.posHist(ii, obj.timestepIndex, 3);
end
end end
drawnow; drawnow;

View File

@@ -28,7 +28,7 @@ function [obj, f] = plotWireframe(obj, ind, f)
o = plot3(f.CurrentAxes, X, Y, Z, '-', 'Color', obj.tag.color, 'LineWidth', 2); o = plot3(f.CurrentAxes, X, Y, Z, '-', 'Color', obj.tag.color, 'LineWidth', 2);
else else
hold(f.Children(1).Children(ind(1)), "on"); hold(f.Children(1).Children(ind(1)), "on");
o = plot3(f.Children(1).Children(ind(1)), X, Y, Z, '-', 'Color', obj.tag.color, 'LineWidth', 2); o = plot3(f.Children(1).Children(ind(1)), X, Y, Z, '-', 'Color', obj.tag.color, 'LineWidth', 1);
hold(f.Children(1).Children(ind(1)), "off"); hold(f.Children(1).Children(ind(1)), "off");
end end