Comments (3)
I haven't tried running your code, but just looking at the points, this jumps out to me:
[ 3.3984917402267456, -14.919993494289331 ],
[ 3.2411990917407074, -14.919993494289326 ]
Notice that the Y coordinates are nearly the same, but not exactly the same. This can cause issues with the floating point precision.
There is a PR here that aims to improve the epsilon logic. You could try applying that patch.
Alternatively, you could round your points before sending them to polybooljs so that they are guaranteed to be the same Y coordinate. For example:
polygon.regions.forEach((region) => {
region.forEach((pt) => {
pt[0] = Math.round(pt[0] * 1000) / 1000;
pt[1] = Math.round(pt[1] * 1000) / 1000;
});
});
I'm curious if that works for you.
from polybooljs.
Hey,
sorry it took so long to get back to you. I somehow missed the GitHub notification about your response, and then since then things have been pretty hectic in my personal life. Even so, I appreciate your super-quick response.
Regarding your suggestions:
- The PR does not solve my issue.
- Rounding the points does work with a factor of 1000. This is the lowest possible factor (that is a power of 10) with which this works, with 100 it doesn't. (Here's a link to the playground I've been using for this, btw.)
- I also tried manually changing the ...326 to ...331 on the last point, which - surprisingly - does not work.
So rounding the points does work. I am a little surprised that it should be necessary, though - after all, this is why we have epsilon logic in the first place, isn't it? The difference between those y-coordinates is ~5e-15, which seems small enough that it should get swallowed.
from polybooljs.
i'm facing the same problem today. Showed by the demo screenshot below resulting a single polygon. It occurs sometimes when there are 2 point are sitting on edge or point of either polygons.
but it is not always the case. i move a point a bit and it give correct result, 2 polygons
I suspect the bug happens when the chainer choose a segment with overlapping points as a starting segment
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
- 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.