ASYLUM: return true if the test point is on the border of the polygon

This commit is contained in:
alxpnv 2021-03-29 15:51:12 +03:00 committed by Eugene Sandulenko
parent 7214a190b0
commit 733f109acc
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -41,11 +41,11 @@ bool Polygon::contains(const Common::Point &point) {
Common::Point *vtx0 = &points[count() - 1];
Common::Point *vtx1 = &points[0];
yflag0 = (vtx0->y >= point.y);
yflag0 = (vtx0->y > point.y);
for (uint32 pt = 0; pt < count(); pt++, vtx1++) {
yflag1 = (vtx1->y >= point.y);
yflag1 = (vtx1->y > point.y);
if (yflag0 != yflag1) {
if (((vtx1->y - point.y) * (vtx0->x - vtx1->x) >= (vtx1->x - point.x) * (vtx0->y - vtx1->y)) == yflag1) {
if (((vtx1->y - point.y) * (vtx0->x - vtx1->x) > (vtx1->x - point.x) * (vtx0->y - vtx1->y)) == yflag1) {
inside_flag = !inside_flag;
}
}