forked from wjxjmj/openMAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotSim.m
50 lines (49 loc) · 1.25 KB
/
plotSim.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
41
42
43
44
45
46
47
48
49
50
function plotSim(tHis,xHis,lHis)
global conf para
tailLength = conf.tailLength;
addpath(genpath(pwd));
[d,n,loop]=size(xHis);
skip = max(floor(loop/conf.show_frame),1);
wHis=dataFlatten(xHis);
wlHis=dataFlatten(lHis);
if d==2
set(gcf,'renderer','painters')
end
[amin, amax, bmin, bmax]=dataGetArea(xHis);
hwait=waitbar(0,'>>>>>>>>>>');
for t=1:loop
if mod(t,skip)>0
continue
end
axis([amin amax bmin bmax]);
clf
hold on
drawAgents(xHis(:,:,1),0);
drawAgents(lHis(:,:,1),0);
drawWake(wHis,d,t,tailLength,'c-')
drawWake(wlHis,d,t,tailLength,'m--')
drawAgents(xHis(:,:,t),1);
drawAgents(lHis(:,:,t),2);
for i=1:n
xi = xHis(:,i,t);
for j=1:n
if i==j
continue
else
xj = xHis(:,j,t);
dis = norm(xi-xj);
if abs(dis-para.la)<=0.005
line([xi(1) xj(1)],[xi(2) xj(2)]);
end
end
end
drawCircle(xi,para.r,'[0.7,0.7,0.7]','--');
end
hold off
axis equal
title(['time = ' num2str(tHis(t)) ' s'],'fontsize',12)
waitbar(t/loop,hwait,'plotting');
end
close(hwait);
rmpath(genpath(pwd));
end