Why points inside a polygon can't be found completely by using "Inpolygon"

9 ビュー (過去 30 日間)
Jiali
Jiali 2022 年 2 月 25 日
編集済み: KSSV 2022 年 2 月 25 日
Dear all,
I would like to find a set of points (red points in the below figure) whether inside another bunch of points (blue points in the below figure). Thus, I use the "inpolygon" command, but stragely only some of points located inside the polygon are returned. Why it happens? how to fix it?
load data.mat
ind=inpolygon(source_xtheta,source_ytheta,xloc,yloc);
figure;
plot(xloc,yloc,'bo');
hold on;
plot(source_xtheta(ind),source_ytheta(ind),'r*');
Figure 1: Problem Definition
Figure 2: Matlab Result

採用された回答

KSSV
KSSV 2022 年 2 月 25 日
編集済み: KSSV 2022 年 2 月 25 日
load('data.mat')
idx = boundary(xloc,yloc) ; % pick the boundary points which form a polygon
ind=inpolygon(source_xtheta,source_ytheta,xloc(idx),yloc(idx));
figure;
plot(xloc,yloc,'b.');
hold on;
plot(source_xtheta(ind),source_ytheta(ind),'r*');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurfaces, Volumes, and Polygons についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by