Competitive Programing Problem Solutions/Geometry/test (2).cpp
bool PointInPolygon(const vector<PT>p, PT q){
    bool c=0;
    int s=p.size();
    for(int i=0,j=s-1; i<s; j=i++){
        if(((p[i].y>q.y)!=(p[j].y>q.y))&&(q.x<p[i].x+(p[j].x-p[i].x)*(q.y-p[i].y)/(p[j].y-p[i].y))) c=!c;
    }
    return c;
}
/// Determines whether a point 'q' is in a possibly non-convex polygon or not.
/// Returns '1' for strictly interior points, '0' for strictly exterior points, and '0' or '1' for the remaining points.

Determines whether a point 'q' is in a possibly non-convex polygon or not.
Determines whether a point ' q ' is in a possibly non - convex polygon or not .
bool PointInPolygon(const vector<PT>p, PT q){
    bool c=0;
    int s=p.size();
    for(int i=0,j=s-1; i<s; j=i++){
        if(((p[i].y>q.y)!=(p[j].y>q.y))&&(q.x<p[i].x+(p[j].x-p[i].x)*(q.y-p[i].y)/(p[j].y-p[i].y))) c=!c;
    }
    return c;
}
bool PointInPolygon ( const vector < PT > p , PT q ) { bool c = 0 ; int s = p . size ( ) ; for ( int i = 0 , j = s - 1 ; i < s ; j = i ++ ) { if ( ( ( p [ i ] . y > q . y ) != ( p [ j ] . y > q . y ) ) && ( q . x < p [ i ] . x + ( p [ j ] . x - p [ i ] . x ) * ( q . y - p [ i ] . y ) / ( p [ j ] . y - p [ i ] . y ) ) ) c = ! c ; } return c ; }
Determines whether a point 'q' is in a possibly non-convex polygon or not.
Determines whether a point ' q ' is in a possibly non - convex polygon or not .