
ボロノイ線図と特定のエリアの領域との交点
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
yusuke kobayashi
le 24 Jan 2019
Modifié(e) : yusuke kobayashi
le 26 Jan 2019
ボロノイ線図を利用して、領域を区分けしたいと思っています。
ある領域(ここでは正方形にしています)と、ボロノイ線図の交点を計算したいのですが、
やり方がわかりません。どなたか知っていませんか?
0 commentaires
Réponse acceptée
Tohru Kikawada
le 25 Jan 2019
Modifié(e) : Tohru Kikawada
le 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 commentaires
Tohru Kikawada
le 25 Jan 2019
yusuke kobayashi
le 26 Jan 2019
Modifié(e) : yusuke kobayashi
le 26 Jan 2019
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!