| Description |
This is Brand new so please advise-me if problems occurs.
Here you can find an m-file with trhee different algorithms for inpolygon test.
Depending on the input data, the one who is estimate to be the best will be chosen.
This version do not support the onpolygon output so tollerance is not necessary. Maybe in my next revision this feature will be added.
I'll be very glad receiving suggestion (even on preferred sintax), questions bug reports.
SYNTAX:
in=InPolyConvex(qx,qy,x,y)
qx : The points to be tested, vector [Nx1] of x coordinate.
qy : The points to be tested, vector [Nx1] of y coordinate.
x : The x coordinate of vertices of the convex polygon [Nx1]
The syntax assumes that the vertices are specified in
consecutive order.
y : The y coordinate of vertices of the convex polygon [Nx1]
The syntax assumes that the vertices are specified in
consecutive order.
in : An Nx1 logical array with IN(i) = TRUE if P(i,:) lies within the
region.
Notes:
-InPolyConvex do not support on polygon options so tollerance is not necessary.
-InPolyConvex do not support edges input format of the polygon.
Maybe in the next revision these two feature will be added.
EXAMPLE:
%query points
Nq=100;
qx=rand(Nq,1);
qy=rand(Nq,1);
%the convex polygon: a square
x=.2+[0,.5,.5,0]';
y=.3+[0,0,.5,.5]';
in=InPolyConvex(qx,qy,x,y);
figure;
hold on
axis equal
plot(x,y)
plot(qx(in),qy(in),'.r');
plot(qx(~in),qy(~in),'.k');
legend('Polygon','Inside','Outside')
|