-
Notifications
You must be signed in to change notification settings - Fork 23
/
PlotModel.m
40 lines (33 loc) · 1.32 KB
/
PlotModel.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
% Plot the terrain model and threats
function PlotModel(model)
mesh(model.X,model.Y,model.H); % Plot the data
colormap summer; % Default color map.
set(gca, 'Position', [0 0 1 1]); % Fill the figure window.
axis equal vis3d on; % Set aspect ratio and turn off axis.
shading interp; % Interpolate color across faces.
material dull; % Mountains aren't shiny.
camlight left; % Add a light over to the left somewhere.
lighting gouraud; % Use decent lighting.
xlabel('x [m]');
ylabel('y [m]');
zlabel('z [m]');
hold on
% Threats as cylinders
threats = model.threats;
threat_num = size(threats,1);
h=250; % Height
for i = 1:threat_num
threat = threats(i,:);
threat_x = threat(1);
threat_y = threat(2);
threat_z = threat(3);
threat_radius = threat(4);
[xc,yc,zc]=cylinder(threat_radius); % create a unit cylinder
% set the center and height
xc=xc+threat_x;
yc=yc+threat_y;
zc=zc*h+threat_z;
c = mesh(xc,yc,zc); % plot the cylinder
set(c,'edgecolor','none','facecolor','#FF0000','FaceAlpha',.3); % set color and transparency
end
end