フィルターのクリア

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)])
  2 件のコメント
Ian Bouchard
Ian Bouchard 2017 年 11 月 30 日
Once again thank you for the help!
KSSV
KSSV 2017 年 11 月 30 日
You are welcome.....:)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDelaunay Triangulation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by