Giter VIP home page Giter VIP logo

Comments (3)

velipso avatar velipso commented on July 21, 2024

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.

BadIdeaException avatar BadIdeaException commented on July 21, 2024

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.

mikhaelmartin avatar mikhaelmartin commented on July 21, 2024

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.

Screenshot from 2023-09-23 09-51-38

but it is not always the case. i move a point a bit and it give correct result, 2 polygons

Screenshot from 2023-09-23 09-51-52

I suspect the bug happens when the chainer choose a segment with overlapping points as a starting segment

from polybooljs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.