correct()
can't "fix" the polygon in all cases. Consider this polygon:
{ 0.0, 0.0 }, { 1.0, 1.0 }, { 0.0, 1.0 }, { 1.0, 0.0 }
It is self-intersecting and runs neither clockwise nor counter-clockwise.
How is correct() supposed to fix it? In fact bg::is_valid(poly)
returns false
before and after bg::correct(poly)
.
However, I used it with Boost 1.82 and got correct results in all cases I tried.
Anyway, I would suggest to use multi_point
instead of polygon
in the case of the OP. I think this would also reduce overhead.
I really wonder why Boost chose polygon
as geometry type in their sample code for convex_hull()
.