added multiple visualization perspectives
This commit is contained in:
10
agent.m
10
agent.m
@@ -52,8 +52,16 @@ classdef agent
|
||||
|
||||
% Plot points representing the agent position
|
||||
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");
|
||||
|
||||
% 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
|
||||
@@ -1,8 +1,44 @@
|
||||
function f = firstPlotSetup(f)
|
||||
if isempty(f.CurrentAxes)
|
||||
axes(f);
|
||||
axis(f.CurrentAxes, "equal");
|
||||
grid(f.CurrentAxes, "on");
|
||||
view(f.CurrentAxes, 3);
|
||||
tiledlayout(f, 4, 3, "TileSpacing", "tight", "Padding", "compact");
|
||||
|
||||
% Top-down view
|
||||
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
|
||||
@@ -180,8 +180,16 @@ classdef rectangularPrism
|
||||
|
||||
% Plot the boundaries of the geometry
|
||||
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");
|
||||
|
||||
% 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
|
||||
@@ -58,12 +58,25 @@ classdef sensingObjective
|
||||
% Create axes if they don't already exist
|
||||
f = firstPlotSetup(f);
|
||||
|
||||
% Plot gradient on the "floor" of the domain
|
||||
hold(f.CurrentAxes, "on");
|
||||
s = surf(obj.X, obj.Y, repmat(obj.groundAlt, size(obj.X)), obj.values ./ max(obj.values, [], "all"), 'EdgeColor', 'none');
|
||||
s.HitTest = 'off';
|
||||
s.PickableParts = 'none';
|
||||
hold(f.CurrentAxes, "off");
|
||||
% Check if this is a tiled layout figure
|
||||
if strcmp(f.Children(1).Type, 'tiledlayout')
|
||||
% Plot gradient on the "floor" of the domain
|
||||
hold(f.Children(1).Children(3), "on");
|
||||
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');
|
||||
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
|
||||
@@ -238,9 +238,9 @@ classdef test_miSim < matlab.unittest.TestCase
|
||||
f = tc.testClass.domain.plotWireframe;
|
||||
|
||||
% Set plotting limits to focus on the domain
|
||||
xlim([tc.testClass.domain.minCorner(1) - 0.5, tc.testClass.domain.maxCorner(1) + 0.5]);
|
||||
ylim([tc.testClass.domain.minCorner(2) - 0.5, tc.testClass.domain.maxCorner(2) + 0.5]);
|
||||
zlim([tc.testClass.domain.minCorner(3) - 0.5, tc.testClass.domain.maxCorner(3) + 0.5]);
|
||||
xlim([tc.testClass.domain.minCorner(1), tc.testClass.domain.maxCorner(1)]);
|
||||
ylim([tc.testClass.domain.minCorner(2), tc.testClass.domain.maxCorner(2)]);
|
||||
zlim([tc.testClass.domain.minCorner(3), tc.testClass.domain.maxCorner(3)]);
|
||||
|
||||
% Plot obstacles
|
||||
for ii = 1:size(tc.testClass.obstacles, 1)
|
||||
|
||||
Reference in New Issue
Block a user