필터 지우기
필터 지우기

Creating a voronoi diagram from incenter points of delaunay traingulation

조회 수: 1 (최근 30일)
Ian Bouchard
Ian Bouchard 2017년 11월 30일
댓글: KSSV 2017년 11월 30일
I am currently trying to create a voronoi diagram off of the incenter points of the delaunay triangulation but I am having a hard time getting the diagram of the voronoi to appear. I also want to confine the diagram within the polygon that I am using but I seem to be failing. Thank you for your help!!
P.S. The .shp file is already in MATLAB's database. I also have received a lot of help with this code from others.
states = shaperead('usastatehi.shp');
st = states(47); %creates a polgon in the shape of Washington State
stBB = st.BoundingBox;
st_minlat = min(stBB(:,2 ));
st_maxlat = max(stBB(:,2 ));
st_latspan = st_maxlat - st_minlat;
st_minlong = min(stBB(:,1 ));
st_maxlong = max(stBB(:,1 ));
st_longspan = st_maxlong - st_minlong;
stX = st.X ;
stY = st.Y;
numPointsIn = 42;
for i = 1:numPointsIn
flagIsIn = 0;
while ~flagIsIn
x(i) = st_minlong + rand(1) * st_longspan ;
y(i) = st_minlat + rand(1) * st_latspan ;
flagIsIn = inpolygon(x(i), y(i), stX, stY );
end
end
mapshow(st, 'edgecolor', 'r', 'facecolor', 'none ')
hold on
scatter(x, y , '.')
dt=delaunayTriangulation(x',y')
IC=incenter(dt)
dt1=delaunayTriangulation(IC)
voronoiDiagram(IC)
hold on
triplot(IC)

채택된 답변

KSSV
KSSV 2017년 11월 30일
편집: KSSV 2017년 11월 30일
states = shaperead('usastatehi.shp');
st = states(47); %creates a polgon in the shape of Washington State
stBB = st.BoundingBox;
st_minlat = min(stBB(:,2 ));
st_maxlat = max(stBB(:,2 ));
st_latspan = st_maxlat - st_minlat;
st_minlong = min(stBB(:,1 ));
st_maxlong = max(stBB(:,1 ));
st_longspan = st_maxlong - st_minlong;
stX = st.X ;
stY = st.Y;
numPointsIn = 42;
for i = 1:numPointsIn
flagIsIn = 0;
while ~flagIsIn
x(i) = st_minlong + rand(1) * st_longspan ;
y(i) = st_minlat + rand(1) * st_latspan ;
flagIsIn = inpolygon(x(i), y(i), stX, stY );
end
end
mapshow(st, 'edgecolor', 'r', 'facecolor', 'none ')
hold on
scatter(x, y , '.')
%
dt=delaunayTriangulation(x',y')
IC=incenter(dt) ;
hold on
triplot(dt)
%
[XV, YV] = voronoi(IC(:,1),IC(:,2));
plot(XV,YV,'g')
axis([min(stX) max(stX) min(stY) max(stY)])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Delaunay Triangulation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by