ボロノイ線図と特定のエリアの領域との交点

4 views (last 30 days)
yusuke kobayashi
yusuke kobayashi on 24 Jan 2019
Edited: yusuke kobayashi on 26 Jan 2019
ボロノイ線図を利用して、領域を区分けしたいと思っています。
ある領域(ここでは正方形にしています)と、ボロノイ線図の交点を計算したいのですが、
やり方がわかりません。どなたか知っていませんか?

Accepted Answer

Tohru Kikawada
Tohru Kikawada on 25 Jan 2019
Edited: Tohru Kikawada on 25 Jan 2019
下記のようなイメージでしょうか。
%% ボロノイ図の作成
x = gallery('uniformdata',[1 10],0);
y = gallery('uniformdata',[1 10],1);
[vx,vy] = voronoi(x,y);
figure, plot(vx,vy,'b-')
axis equal;
axis([0 1 0 1]);
%% 正方形の領域定義
poly1 = polyshape([0.25 0.25 0.75 0.75],[0.75 0.25 0.25 0.75]);
hold on;
plot(poly1)
%% 正方形の辺とボロノイ図の辺の交点を検出
for k = 1:size(vx,2)
% 交点を検出
[in,out] = intersect(poly1,[vx(:,k) vy(:,k)]);
plot(in(:,1),in(:,2),'b',out(:,1),out(:,2),'r')
% 交点座標を抽出
if ~isempty(in) && ~isempty(out)
ind = ismember(in,out,'rows');
intxy = in(ind,:);
plot(intxy(1),intxy(2),'ro');
end
end
  5 Comments
yusuke kobayashi
yusuke kobayashi on 26 Jan 2019
Edited: yusuke kobayashi on 26 Jan 2019
その方法をやってみようと思って、下のように書いてはみたのですが、
polyshape は inf を扱えないと言われて跳ね返されてしまいます。
[v,c] = voronoin(X);
%外形の領域の定義
poly1 = polyshape([0 1 1 0],[0 0 1 1]);
hold on
for k = 1:size(X(:,1),2)
Region = [v(c{k},1),v(c{k},2)];
poly2 = polyshape(Region);
hold on
Overlap = intersect(poly1,poly2);
Area = polyshape(Overlap.Vertices);
plot(Area,'Facecolor','g')
end     

Sign in to comment.

More Answers (0)

Categories

Find more on ボロノイ線図 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!