Giter VIP home page Giter VIP logo

Comments (5)

velipso avatar velipso commented on August 22, 2024

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.

vidit1 avatar vidit1 commented on August 22, 2024

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.

velipso avatar velipso commented on August 22, 2024

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.

vidit1 avatar vidit1 commented on August 22, 2024

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.

velipso avatar velipso commented on August 22, 2024

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.

screen shot 2018-04-26 at 8 28 40 am

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.