refactored constraint plotting to remove superfluous property

This commit is contained in:
2026-03-31 22:10:43 -07:00
parent 0bcdd73882
commit 8da65278a2
6 changed files with 22 additions and 19 deletions
+13 -4
View File
@@ -6,6 +6,10 @@ function obj = plotH(obj)
obj (1, 1) {mustBeA(obj, "miSim")};
end
nCA = size(obj.agents, 1) * (size(obj.agents, 1) - 1) / 2;
nObs = size(obj.agents, 1) * size(obj.obstacles, 1);
nDom = size(obj.agents, 1) * 6;
obj.hf = figure;
tiledlayout(obj.hf, 4, 1, "TileSpacing", "tight", "Padding", "compact");
@@ -15,7 +19,7 @@ function obj = plotH(obj)
xlabel(obj.hf.Children(1).Children(1), "Time (s)");
title(obj.hf.Children(1).Children(1), "Collision Avoidance");
hold(obj.hf.Children(1).Children(1), "on");
obj.caPlot = plot(obj.h(1:(size(obj.agents, 1) * (size(obj.agents, 1) - 1) / 2), :)');
obj.caPlot = plot(obj.barriers(1:nCA, :)');
legendStrings = [];
for ii = 2:size(obj.agents, 1)
for jj = 1:(ii - 1)
@@ -31,7 +35,7 @@ function obj = plotH(obj)
xlabel(obj.hf.Children(1).Children(1), "Time (s)");
title(obj.hf.Children(1).Children(1), "Obstacles");
hold(obj.hf.Children(1).Children(1), "on");
obj.obsPlot = plot(obj.h((1 + (size(obj.agents, 1) * (size(obj.agents, 1) - 1) / 2)):(((size(obj.agents, 1) * (size(obj.agents, 1) - 1) / 2)) + size(obj.agents, 1) * size(obj.obstacles, 1)), :)');
obj.obsPlot = plot(obj.barriers((nCA + 1):(nCA + nObs), :)');
legendStrings = [];
for ii = 1:size(obj.obstacles, 1)
for jj = 1:size(obj.agents, 1)
@@ -47,8 +51,13 @@ function obj = plotH(obj)
xlabel(obj.hf.Children(1).Children(1), "Time (s)");
title(obj.hf.Children(1).Children(1), "Domain");
hold(obj.hf.Children(1).Children(1), "on");
obj.domPlot = plot(obj.h((1 + (((size(obj.agents, 1) * (size(obj.agents, 1) - 1) / 2)) + size(obj.agents, 1) * size(obj.obstacles, 1))):size(obj.h, 1), 1:end)');
legend(obj.hf.Children(1).Children(1), ["X Min"; "X Max"; "Y Min"; "Y Max"; "Z Min"; "Z Max";], "Location", "bestoutside");
obj.domPlot = plot(obj.barriers((nCA + nObs + 1):(nCA + nObs + nDom), :)');
domLabels = ["X Min", "X Max", "Y Min", "Y Max", "Z Min", "Z Max"];
legendStrings = strings(nDom, 1);
for ii = 1:size(obj.agents, 1)
legendStrings((ii - 1) * 6 + (1:6)) = sprintf("A%d ", ii) + domLabels;
end
legend(obj.hf.Children(1).Children(1), legendStrings, "Location", "bestoutside");
hold(obj.hf.Children(1).Children(2), "off");
nexttile(obj.hf.Children(1));