Scilab Function
Last update : 3/11/2005

intriang - Are points within a triangle ?

Calling Sequence

Q = intriang(ptri,points)

Parameters

Description

PTRI is a complex vector of length 3, which contains the corners of a triangle. POINTS is a complex vector or a matrix with points, which are checked, if they are within the triangle. Q is a binary Matrix with the same dimension like the matrix or vector POINTS. A 1 is used for points, which are within or on the corner of the triangle.

The decision is done by the checking the sum of areas, which are build from the point and the triangle.

Examples

pl=[0,4,(3+2*%i)] + (2+3*%i)
[X,Y]=ndgrid(0.3:0.5:7,0.3:0.5:7);
points=X + %i .*Y;
Q=intriang(pl,points);
// Draw the triangle
plot2d(real([pl,pl(1)]),imag([pl,pl(1)]),style=2);
X1=X(Q==1); Y1=Y(Q==1);
X2=X(Q==0); Y2=Y(Q==0);
// Plot the points
plot2d(X1,Y1,style=-3);
plot2d(X2,Y2,style=-4);
// end of example

See Also

adreieck ,   intriang ,  

Authors

Dr. Andreas Geissler geisslea@web.de

Used Function

adreieck