added multiple visualization perspectives

This commit is contained in:
2025-10-27 09:22:20 -07:00
parent d0a060f404
commit 8af5e87272
5 changed files with 80 additions and 15 deletions

10
agent.m
View File

@@ -52,8 +52,16 @@ classdef agent
% Plot points representing the agent position % Plot points representing the agent position
hold(f.CurrentAxes, "on"); hold(f.CurrentAxes, "on");
scatter3(obj.pos(1), obj.pos(2), obj.pos(3), 'filled', 'ko', 'SizeData', 50); o = scatter3(obj.pos(1), obj.pos(2), obj.pos(3), 'filled', 'ko', 'SizeData', 25);
hold(f.CurrentAxes, "off"); hold(f.CurrentAxes, "off");
% Check if this is a tiled layout figure
if strcmp(f.Children(1).Type, 'tiledlayout')
% Add to other perspectives
copyobj(o, f.Children(1).Children(2));
copyobj(o, f.Children(1).Children(3));
copyobj(o, f.Children(1).Children(5));
end
end end
end end
end end

View File

@@ -1,8 +1,44 @@
function f = firstPlotSetup(f) function f = firstPlotSetup(f)
if isempty(f.CurrentAxes) if isempty(f.CurrentAxes)
axes(f); tiledlayout(f, 4, 3, "TileSpacing", "tight", "Padding", "compact");
axis(f.CurrentAxes, "equal");
grid(f.CurrentAxes, "on"); % Top-down view
view(f.CurrentAxes, 3); nexttile(1, [1, 2]);
axes(f.Children(1).Children(1));
axis(f.Children(1).Children(1), "image");
grid(f.Children(1).Children(1), "on");
view(f.Children(1).Children(1), 0, 90);
xlabel(f.Children(1).Children(1), "X"); ylabel(f.Children(1).Children(1), "Y");
% Communications graph
nexttile(3, [1, 1]);
axes(f.Children(1).Children(1));
axis(f.Children(1).Children(1), "image");
grid(f.Children(1).Children(1), "off");
view(f.Children(1).Children(1), 0, 0);
% 3D view
nexttile(4, [2, 2]);
axes(f.Children(1).Children(1));
axis(f.Children(1).Children(1), "image");
grid(f.Children(1).Children(1), "on");
view(f.Children(1).Children(1), 3);
xlabel(f.Children(1).Children(1), "X"); ylabel(f.Children(1).Children(1), "Y"); zlabel(f.Children(1).Children(1), "Z");
% Side-on view
nexttile(6, [2, 1]);
axes(f.Children(1).Children(1));
axis(f.Children(1).Children(1), "image");
grid(f.Children(1).Children(1), "on");
view(f.Children(1).Children(1), 90, 0);
ylabel(f.Children(1).Children(1), "Y"); zlabel(f.Children(1).Children(1), "Z");
% Front-on view
nexttile(10, [1, 2]);
axes(f.Children(1).Children(1));
axis(f.Children(1).Children(1), "image");
grid(f.Children(1).Children(1), "on");
view(f.Children(1).Children(1), 0, 0);
xlabel(f.Children(1).Children(1), "X"); zlabel(f.Children(1).Children(1), "Z");
end end
end end

View File

@@ -180,8 +180,16 @@ classdef rectangularPrism
% Plot the boundaries of the geometry % Plot the boundaries of the geometry
hold(f.CurrentAxes, "on"); hold(f.CurrentAxes, "on");
plot3(X, Y, Z, '-', 'Color', obj.tag.color, 'LineWidth', 2); o = plot3(X, Y, Z, '-', 'Color', obj.tag.color, 'LineWidth', 2);
hold(f.CurrentAxes, "off"); hold(f.CurrentAxes, "off");
% Check if this is a tiled layout figure
if strcmp(f.Children(1).Type, 'tiledlayout')
% Add to other perspectives
copyobj(o, f.Children(1).Children(2));
copyobj(o, f.Children(1).Children(3));
copyobj(o, f.Children(1).Children(5));
end
end end
end end
end end

View File

@@ -58,12 +58,25 @@ classdef sensingObjective
% Create axes if they don't already exist % Create axes if they don't already exist
f = firstPlotSetup(f); f = firstPlotSetup(f);
% Plot gradient on the "floor" of the domain % Check if this is a tiled layout figure
hold(f.CurrentAxes, "on"); if strcmp(f.Children(1).Type, 'tiledlayout')
s = surf(obj.X, obj.Y, repmat(obj.groundAlt, size(obj.X)), obj.values ./ max(obj.values, [], "all"), 'EdgeColor', 'none'); % Plot gradient on the "floor" of the domain
s.HitTest = 'off'; hold(f.Children(1).Children(3), "on");
s.PickableParts = 'none'; o = surf(f.Children(1).Children(3), obj.X, obj.Y, repmat(obj.groundAlt, size(obj.X)), obj.values ./ max(obj.values, [], "all"), 'EdgeColor', 'none');
hold(f.CurrentAxes, "off"); o.HitTest = 'off';
o.PickableParts = 'none';
hold(f.Children(1).Children(3), "off");
% Add to other perspectives
copyobj(o, f.Children(1).Children(5));
else
% Plot gradient on the "floor" of the domain
hold(f.CurrentAxes, "on");
o = surf(obj.X, obj.Y, repmat(obj.groundAlt, size(obj.X)), obj.values ./ max(obj.values, [], "all"), 'EdgeColor', 'none');
o.HitTest = 'off';
o.PickableParts = 'none';
hold(f.CurrentAxes, "off");
end
end end
end end
end end

View File

@@ -238,9 +238,9 @@ classdef test_miSim < matlab.unittest.TestCase
f = tc.testClass.domain.plotWireframe; f = tc.testClass.domain.plotWireframe;
% Set plotting limits to focus on the domain % Set plotting limits to focus on the domain
xlim([tc.testClass.domain.minCorner(1) - 0.5, tc.testClass.domain.maxCorner(1) + 0.5]); xlim([tc.testClass.domain.minCorner(1), tc.testClass.domain.maxCorner(1)]);
ylim([tc.testClass.domain.minCorner(2) - 0.5, tc.testClass.domain.maxCorner(2) + 0.5]); ylim([tc.testClass.domain.minCorner(2), tc.testClass.domain.maxCorner(2)]);
zlim([tc.testClass.domain.minCorner(3) - 0.5, tc.testClass.domain.maxCorner(3) + 0.5]); zlim([tc.testClass.domain.minCorner(3), tc.testClass.domain.maxCorner(3)]);
% Plot obstacles % Plot obstacles
for ii = 1:size(tc.testClass.obstacles, 1) for ii = 1:size(tc.testClass.obstacles, 1)