How can I get the area of each polygon of a voronoi diagram?

48 次查看(过去 30 天)
I need to find areas of all the polygons inside a voronoi diagram and then alot diffrent properties based on different areas. I know the co-ordiantes of all the polygons but cannot distinguish between the ones forming the specific polygon

采纳的回答

KSSV
KSSV 2019-2-21
x = rand(10,1) ; y = rand(10,1) ;
[v,c] = voronoin([x y]) ;
figure
hold on
voronoi(x,y)
A = zeros(length(c),1) ;
for i = 1:length(c)
v1 = v(c{i},1) ;
v2 = v(c{i},2) ;
patch(v1,v2,rand(1,3))
A(i) = polyarea(v1,v2) ;
end
  4 个评论
DGM
DGM 2023-3-20
编辑:DGM 2023-3-20
Any update on what? On the area of open cells? On the attempt to force the cell areas to have a specific truncated gaussian distribution?
The area of the open cells is arguably infinite. The diagram is a partitioning of a plane. When used to plot the diagram, voronoi() just picks some plot extents that are a bit more than sufficiently large to contain all the seed points. The amount of extra area chosen is simply determined by the default behavior of plot(). The size of the plot box chosen by voronoi() has no meaning relevant to the concepts under study, so neither does the area of open cells, if open cells are considered to have finite area defined by the plot box.
That said, KSSV's example gives the area for all closed cells, but not all closed cells are contained within the plot box. So the question is which areas matter? If there's some box constraint used to truncate open cells, does it also truncate closed cells? What defines it?
% open cells are not finite
% not all closed cells lie within the default plot box
rng(123)
x = rand(10,1);
y = rand(10,1);
voronoi(x,y);
xb = xlim;
yb = ylim;
hold on;
hp = plot(xb([1 2 2 1 1]),yb([1 1 2 2 1]));
xlim([-1.5 2.5])
ylim([-1.5 2.5])
legend(hp,'default plot box')

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Voronoi Diagram 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by