-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain7.m
86 lines (75 loc) · 1.61 KB
/
main7.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
clear all;clc;clf;
addpath dataSet voronoi functions
load(sprintf('bestEllipse%d',1))
%# simulation parameters
robot=[1 1];
rois=bestEllipse;
findROIs=[];
step=1;
% # generate random voronoi partition
subplot(2,3,step)
[vx,vy,x,y]=area_partition();
plot(x,y,'r+',vx,vy,'b-')
hold on
subplot(2,3,step+1)
for c=1:length(vx)
hh(c,:)=createEdge([vx(1,c), vy(1,c)],[vx(2,c), vy(2,c)]);
end
for h=hh'
drawEdge(h');
hold on
end
bound=[1 50 1 50];
axis(bound)
[mm nn]=meshgrid([1 50],[50 1]);
c1=cat(2,mm',nn');
c2=cat(2,mm,nn);
cc=[c1;c2];
px=[];py=[];
for h=hh'
for c=cc'
point = intersectEdges(h', c');
if (~isnan(point))
%update that edge
px=[px;point(1)];
py=[py;point(2)];
%find cycle in order to find voronoi region
end
end
end
plot(px,py,'r+')
drawBox(bound)
%%
centroids=[x' y'];
% find the nearest centroid
centroid_mask=[];
ind=emin(centroids ,robot,centroid_mask );
centroid_mask=[centroid_mask;ind];
while (step<3)
% update windows
subplot(2,3,step+1)
%connect the centroid
edge=createEdge(robot, [x(ind), y(ind)])
drawEdge(x(ind), y(ind), robot(1), robot(2));
% find intesection with any ellipse
candidateROIs = found_roi( rois,edge );
%draw candidate rois
for ii=candidateROIs
hold on
drawEllipse(rois(ii,:));
end
%update area parition
findROIs=[findROIs;rois(candidateROIs,:)];
rois(candidateROIs,:)
[vx,vy,x,y]=area_partition(findROIs);
%update centroids
centroids=[x y]
%update rois
rois(candidateROIs,:)=[];
%update robot position
robot=[13.3243 6.6890]
step=step+1;
plot(x,y,'r+',vx,vy,'b-')
%move to next candidate
ind=3;
end