VovKa my brain is a little burned. . .
... be clearer ...
to do a test, I draw a polyline made of only segments,
where many consecutive segments have the same angle ...
...
... then I extract all the vertices and pass them to my function ...
and then I draw the new polyline that does not contain consecutive aligned segments ...
...
and it seems to me that it works fine!
The list of points you sent me is made up
of many segments that differ by a very small angle
... just adjust the ang-fuzz value ...
...
I know you never talk nonsense. . . but help me to understand better, please.