![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/201448/image.jpeg)
ボロノイ線図と特定のエリアの領域との交点
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
yusuke kobayashi
il 24 Gen 2019
Modificato: yusuke kobayashi
il 26 Gen 2019
ボロノイ線図を利用して、領域を区分けしたいと思っています。
ある領域(ここでは正方形にしています)と、ボロノイ線図の交点を計算したいのですが、
やり方がわかりません。どなたか知っていませんか?
0 Commenti
Risposta accettata
Tohru Kikawada
il 25 Gen 2019
Modificato: Tohru Kikawada
il 25 Gen 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/201448/image.jpeg)
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!