필터 지우기
필터 지우기

How to make a node move to a new position so that all the vertices can be covered?

조회 수: 2 (최근 30일)
Every cell has its own node. All the vertices of a cell has to be covered by any of the nodes. I have set the sensing radius of the nodes as 0.8 here (Which means vertices falling within that radius will only be covered). How can i make the nodes move so that all the vertices be covered by any of the nodes? The following is the code i have written so far:
x=[1 1 1 2 2 2 3 3 3 3 4 4 4 4 5 5];
y=[1 3 5 2 3 4 1 2 3 5 1 2 4 5 1 2];
N=[x' y'];
axis([0 10 0 10]);
hold on;
scatter(x,y, [], 'filled');
voronoi(x,y,'green');
[vx,vy]=voronoi(x,y);
%Drawing Sensing radius cirlce around the nodes
hold on;
si=size(x);
for i=1:si(2)
radius = 0.8;
centerX = x(1,i);
centerY = y(1,i);
rectangle('Position',[centerX - radius, centerY - radius, radius*2, radius*2],...
'Curvature',[1,1]);
axis square;
end
%p = rand(10,2);
labels = cellstr( num2str([1:16]') ); %' # labels correspond to their order
plot(N(:,1), N(:,2), 'bx')
text(N(:,1), N(:,2), labels, 'VerticalAlignment','bottom', ...
'HorizontalAlignment','right')
plot(vx,vy,'rx');
grid on;
[V C]=voronoin(N);

답변 (1개)

Walter Roberson
Walter Roberson 2018년 6월 8일
Probably the easiest way is to use the centroid of the cell as the location of the node. If the centroid is more than 0.8 away from any of the vertices then it is not possible for a single node to cover all of the vertices.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by