tolerance and edge
Closed this issue · 1 comments
Fast, well documented function. Great work. Thanks.
I think there are issues finding what's on the polygon when tol is specified.
I have some example images. I created a meshgrid and used a large tolerance for demonstration, but the issue remains with more reasonable tolerance values. Because of the rectangular search area no tolerance is used at the corners. There are inconsistencies at the nodes and the width of the applied tolerance is not constant at different locations.
px=[0 -1 0.5 2 3 0 ]';
py=[-3 1 2 3 2 -3 ]';
dx=0.1;
x=linspace(min(px)-dx,max(px)+dx,200);
y=linspace(min(py)-dx,max(py)+dx,400);
[x,y]=meshgrid(x,y);
x=x(:);
y=y(:);
hfp(px,py,'b-','linewidth',4)
hfp(px,py,'bo','markersize',18)
hfp(x,y,'r.')
axis equal
[in,on] = inpoly2([x,y],[px,py],[],1e-2);
in2=in & ~on;
hfp(x(in2),y(in2),'b.')
hfp(x(on),y(on),'ks')
hfp(px,py,'g-','linewidth',4)
hfp(px,py,'go','markersize',18)
@husdemir, the latest PR should address this --- the BNDS
calculation is now scaled differently to give more uniform output. For your test case, the following should now be returned:
I don't expect that BNDS
should be used to calculate exact distances to polygons, but hopefully this is a little better behaved.
Thanks for looking into this.