How can I get the area of each polygon of a voronoi diagram?
47 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
KSSV
on 21 Feb 2019
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 Comments
DGM
on 20 Mar 2023
Edited: DGM
on 20 Mar 2023
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')
More Answers (0)
See Also
Categories
Find more on Voronoi Diagram in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!