Comments (5)
The result is still correct though, right?
Why do you think this behavior is a bug?
The first result is a big region, that hits [25,15]
twice... the second result is two regions, both of which contain [25,15]
. Either representation is valid, unless I'm missing something.
from polybooljs.
The data is inconsistent.
I have to check if union of 2 or more polygon results in a single polygon, In first case that is true but in second case it is false. There is no single source of truth.
from polybooljs.
A union can always return multiple regions. That's the nature of union. Here's a trivial example:
It might help you to read through how the algorithm works -- I have a tutorial here.
This library makes no promise about the number of regions returned, and has no preference for smaller lists of regions.
The data is consistent in the sense that the same input will always return the same output. But different input results in different output. You changed the data, so the algorithm pieces together the result in a different way, with no preference for region count, and produces two regions instead of one. This is normal behavior.
from polybooljs.
You are correct union can return multiple polygon.
That is what i am looking for, i want to check that when i perform a union operation on 2 or more polygons the result is a single polygon or not.
In the library when 2 polygons are linked through a single point, union operation returns sometimes single polygon and sometimes multiple polygon.
I just want to know why this is happening.
from polybooljs.
It has to deal with the segment chaining algorithm.
If you use the animation on the demo page, and hit Left/Right, you can see the segment chaining process.
The order that the segments are added determines whether there are one or two regions. This order is dependent on the vertical alignment.
In the below pic, point B is to the right of point A -- this means that when the chaining is happening (below), it will add the segment C->A before the segment C->B. The highlighted segment then doesn't complete a loop, so the result will be a single region.
If instead point B is to the left of point A, then C->B will be added first, closing the region. Then when C->A is added, it creates a new chain, that eventually turns into the second region.
from polybooljs.
Related Issues (20)
- algorithm comparison
- Speed improvement HOT 8
- Suggestion: Area HOT 1
- union result is wrong
- polybool java HOT 1
- Union completely ignoring some polygons HOT 4
- Holes (again) HOT 2
- Feature Request: a way to cleanup polygons with zero-length segments HOT 1
- I made a demo game based on polybooljs, looking for performance improvements. HOT 1
- Hello, the performance of this library is very low, and the calculation is very slow. When can we have an optimized version? HOT 1
- Consider adding line segments HOT 2
- Zero length segments created HOT 1
- Yet another Java implementation HOT 3
- Cut polygon by line HOT 2
- getting intersection points HOT 2
- About porting the libary to antoher languages HOT 1
- Polygon subtraction creates degenerate result polygon HOT 3
- python port HOT 5
- Adapt code for polyline clipping.
- Geometric meaning of epsilon?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polybooljs.