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

1 次查看(过去 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.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by