Difference(A, B) != Difference(A, Intersection(A, B)) #922
Replies: 6 comments
-
See: https://www.angusj.com/clipper2/Docs/Overview.htm#closed_paths |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer (and this awesome library). My issue is that the image for "Difference(A, Intersection(A, B))" is one path (paths.size() == 1) and a follow up Union doesn't change anything. This absolutely might be the "correct" behavior, even if logically i'd expect Difference(A, B) == Difference(A, Intersection(A, B)) to be the same. |
Beta Was this translation helpful? Give feedback.
-
As above, have you tried |
Beta Was this translation helpful? Give feedback.
-
Yes i did, all above images are after an additional union at the end |
Beta Was this translation helpful? Give feedback.
-
So in conclusion am i right in assuming this isn't a "bug" and for what i need i'd need to roll my own post-processing step ? (Maybe simply checking for each segments if it lies on another segment within some epsilon and if so split into two paths) |
Beta Was this translation helpful? Give feedback.
-
Yes 😁. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Logically, at least to my mind, Difference(A, B) should be equal to Difference(A, Intersection(A, B)), but that doesn't seem to be the case.
I am working only with integer paths.
So my question is a) is this a bug ?
and b) if not does someone have a hint how i could convert the result of Difference(A, Intersection(A, B)) to be the same, or at
least extremely similar to Difference(A, B) ?
The only way i found so far is to offset the result twice with a small value (first with negative, then with positive offset).
This leads to issues down the line though.
Sorry i can't share my test code at the moment as i am using the C++ Clipper bindings in another language.
But maybe these images will help demonstrating my issue:
The A and B polygons:

The result of Difference(A, B)

The result of Difference(A, Intersection(A, B))

The issue only occurs with non "straight" lines / polygons (In my test Offset(Vector2(510, 0), Vector2(500, 500), 20), 20) and offset(Vector2(0, 250), Vector2(1000, 250), 20)) so i assume the reason is internal rounding when finding the intersection points ?
Beta Was this translation helpful? Give feedback.
All reactions