Professional Documents
Culture Documents
Geometry Library by Sourabh Aggarwal (111601025)
Geometry Library by Sourabh Aggarwal (111601025)
return false;
}
double polya = areap(poly);
if(abs(polya) < EPS) { //that means we
have a line;
point a = poly[0], b =
poly[poly.size() - 2];
line ab;
pointsToLine(a, b, ab);
if(tochk.x >= min(a.x, b.x) && tochk.x
<= max(a.x, b.x) && tochk.y >= min(a.y, b.y)
&& tochk.y <= max(a.y, b.y)) {
if(abs(ab.a * tochk.x + ab.b *
tochk.y + ab.c) < EPS) return true;
return false;
}
else return false;
}
double areacmp = 0;
for(int i = 0; i < poly.size() - 1; i++) {
point a = poly[i], b = poly[i + 1];
areacmp += tria(a, b, tochk);
}
return abs(polya - areacmp) < EPS;
}