alexbol99 / flatten-js

Javascript library for 2d geometry
MIT License
553 stars 58 forks source link

Infinite loop when subtracting polygons (v1.2.20) #81

Closed PontusHorn closed 1 year ago

PontusHorn commented 3 years ago

This might be a duplicate of one of the existing issues with similar errors, but I figured I'd add my case here.

Using version 1.2.20, certain polygon operations seems to fail with an "infinite loop" error, either when using Polygon.contains on it, or when subtracting another polygon from it.

Sandbox replication: https://codesandbox.io/s/agitated-minsky-2joft?file=/src/index.js

alexbol99 commented 3 years ago

Hello, @PontusHorn ,

Bug fixed in the patch v1.2.21. Please keep on reporting any problems you have with this library

Thank you for cooperation, Alex Bol

DeveloperUX commented 1 year ago

Running to this issue using flatten-js v1.3.4

This happens when calling Flatten.BooleanOperations.intersect on 2 polygons which are have a similar rotation.

Uncaught Error: Infinite loop
    at get INFINITE_LOOP [as INFINITE_LOOP] (main.esm.js:187:1)
    at LinkedList.testInfiniteLoop (main.esm.js:244:1)
    at restoreFaces (main.esm.js:1377:1)
    at swapLinksAndRestore (main.esm.js:918:1)
    at booleanOpBinary (main.esm.js:950:1)
    at intersect (main.esm.js:794:1)