Open ChrisVilches opened 2 months ago
prev_i = 0;
prev_j = 0;
vector<Point> poly{Point{0, 0}, Point{8, 0}, Point{8, 6}};
assert(intersection(poly, poly));
this fails
It should work (i.e. detect an intersection) since it's the same polygon
I think the logic I implemented doesn't check for when a polygon is completely inside another polygon, and no edges are touching.
It seems the algorithm only works when edges or vertices are touching.
But it seems this works anyway, because the polygons are always touching in every check. It checks whether they are just touching, or one edge goes "inside" the other polygon, correctly. So it works.
What to do with this issue? Just close it? Or change method name? (that would require me changing the name in the Rust project as well, maybe).
UPDATE: This logic would be correct for this problem because this problem is trying to find the maximum perimeter overlapping (edges that match), so if the polygon is completely inside, the result would be zero anyway. For that reason, it's not necessary to check intersections when one polygon is completely contained inside the other.
However, there is another bug: When the polygons are the same (exact same sequence of points), the algorithm fails to detect an intersection. This seems like a worse issue than the above, since this actually could happen in the problem, but it seems it never happens anyway (in such a case, the answer will be the perimeter of the polygons, and the match would be complete)