You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that flattenedPointsAreClockwise may return wrong value for self-intersecting polygons.
For example it returns true for: (0,0) (9,0) (0,10) (10,10)
But returns false for: 0,0) (11,0) (0,10) (10,10)
To be more specific - the returned values says whether the polygon is "mostly clockwise" or not. It is not information that all neighbouring edges are clockwise. And for self-intersecting points orientation is undefined.
The text was updated successfully, but these errors were encountered:
luckyclan
changed the title
flattenedPointsAreClockwise - sometimes wrong result for rotated rectangle
flattenedPointsAreClockwise - unexpected results for self-intersecting polygons
Feb 28, 2024
@luckyclan thanks for reporting this. I'm curious how you bumped into it though since the method is internal. Is there a way to reproduce this issue using public APIs?
I'm author of Artstudio Pro app I just use similar function in my own (closed source) graphic library in Swift, and i encounter the same issue. So i started checking how is it implemented in other libraries, and it turned out that nobody cares of this case.
"isClockwise" is very imporatant function for asserts, it helps to find a lot of bugs.
I think Euclid is great and i often use it to learn how this and that works, how to write good code etc. I just wanted to help to improve it a bit ;)
I can write that In my library i just added: assert(isPolygonSelfIntersecting() == false)
I found that flattenedPointsAreClockwise may return wrong value for self-intersecting polygons.
For example it returns true for:
(0,0) (9,0) (0,10) (10,10)
But returns false for:
0,0) (11,0) (0,10) (10,10)
To be more specific - the returned values says whether the polygon is "mostly clockwise" or not. It is not information that all neighbouring edges are clockwise. And for self-intersecting points orientation is undefined.
Suggestion: add
assert(pointsAreSelfIntersecting(points) == false)
More informations:
https://en.wikipedia.org/wiki/Curve_orientation
The text was updated successfully, but these errors were encountered: