How select data just out from a polygon, considering a constraint

3 Ansichten (letzte 30 Tage)
borders % matrix 20x2 with the x and y coordinates of the generic polygon perimeter
datas % matrix 550x2 containing the x and y coordinates of all my datas
Using the function "inpolygon" I'm able to find all the points of "datas" that are inside the polygon perimeter defined by "borders".
However, I also want to take into account all the points that are outside the polygon and near the perimeter.
More precisely, I want to consider all the points outside the polygon for which the distance in x is lower than 0.3 and the distance in y is lower than 0.1, with respect to the border.
Hoping to be clear, thanks for help!

Akzeptierte Antwort

Matt J
Matt J am 13 Sep. 2021
Bearbeitet: Matt J am 13 Sep. 2021
borders=[0,0;0,1;1 1;1 0];
p=polyshape(borders);
p=blurHull(p,[0.3,0]);
p=blurHull(p,[0, 0.1]);
isinterior(p,datas)
function ps=blurHull(p,v)
N=100;
t=linspace(-1,1,N).'*v;
ps=p;
for i=1:size(t,1)
ps=union(ps,translate(p,t(i,:)));
end
d=2/N;
ps=polybuffer(ps,d,'JointType','square');
ps=polybuffer(ps,-d,'JointType','square');
end

Weitere Antworten (1)

KSSV
KSSV am 13 Sep. 2021
Read about knnsearch. This will give you indices of points lying closer to the given set of points from a set of points along with distances. You can play around with distances obtained from here.

Kategorien

Mehr zu Elementary Polygons finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by