Scilab Function
Last update : 3/11/2005

ipolygon - Points within a closed polygon ?

Calling Sequence

Q = ipolygon(p,points)

Parameters

Description

From the complex points P the convex hull is calculated. (P can even specify the convex hull itself). The complex POINTS (Matrix or Vektor) are checked, whether they are located on the border or within the polygon. Result is a boolean matrix with the same dimension as POINT. ipolygon uses functions intriang (checks if a point is within a triangle) and adreieck (calculate area of triangle). The complete function makes at 1st a delaunay triangulation, then it is checked, whether the points are in one of these triangles.

Examples

x=0.1:0.1:0.9;
y=x;
[X,Y]=ndgrid(x,y);
Z=X + %i .*Y; // POINTS
phi=0:30:360;
p=(0.5 + %i .*0.5) + 0.3 .*exp(%i .*%pi .*phi/180);
Q=ipolygon(p,Z);
Q1=Z(Q==1);
Q2=Z(Q==0);
plot2d(real(Q2),imag(Q2),style=-3);
plot2d(real(Q1),imag(Q1),style=-4);
plot2d(real(p),imag(p),style=2);

See Also

delaunay ,  

Authors

Dr. Andreas Geissler geisslea@web.de

Used Function

delaunayintriang