how to bound voronoi polygons
조회 수: 14 (최근 30일)
이전 댓글 표시
Hi.
I have a set of data points inside a circle of given radius and I am trying to form the closed Voronoi polygons for each data point and then calculate the area of polygon so formed. The problem is with the outermost points. For these points, the voronoi polygon so formed are not bounded or in some case the polygon goes beyond the circle. How can I form a closed polygon for these outermost point? Please help
PS: I have attached the data set and the figures (Fig 1 & Fig 2)showing the voronoi polygons for this data set. The radius of circle is 3 unit. Fig 1 shows only the voronoi polygons and Fig 2 shows the corresponding location of data points over the voronoi polygon
Code:
X = xlsread('Data.xlsx', 'Sheet1','A2:A1823');
Y = xlsread('Data.xlsx', 'Sheet1','B2:B1823');
% Voronoi polygon area
[vv,cc] = voronoin([X Y]);
Ar = zeros(length(cc),1) ; % area
for i = 1:length(cc)
v1 = vv(cc{i},1); v2 = vv(cc{i},2);
patch(v1,v2,rand(1,3))
Ar(i) = polyarea(v1,v2);
end
댓글 수: 0
답변 (1개)
Bruno Luong
2022년 8월 1일
Transform the voronoi cells to polyshape object, you can then make the intersection of the region you want to use to clip (the big circle).
댓글 수: 2
Bruno Luong
2022년 8월 1일
Click on the link on polyshape I give above. Mostly you construct the object by giving the vertices coordinates.
참고 항목
카테고리
Help Center 및 File Exchange에서 Voronoi Diagram에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!