Skip to content

Polygon subtraction creates degenerate result polygon #40

@BadIdeaException

Description

@BadIdeaException

With the below polygons, subtracting S from T creates a degenerate result polygon: Instead of splitting the result into two polygons at vertex 3, it creates a single polygon with vertex 3 sitting on the edge connecting vertex 0 and 1.

I'm not sure if this is intended behavior? With other vertex-on-edge scenarios, result polygons always get split up correctly, so I think this is probably a bug.

var polybooljs = require("polybooljs")

const T = {
    inverted: false,
    regions: [[
        [ 3.1827730120236866, -14.647299060696893 ],
        [ 3.292779172743269, -14.709442780204576 ],
        [ 3.2790977409099513, -15.096879410975502 ]
    ]]
};
const S = {
    inverted: false,
    regions: [[
        [ 3.3984917402267456, -14.277922392125454 ],
        [ 3.3984917402267456, -14.919993494289331 ],
        [ 3.2411990917407074, -14.919993494289326 ]
    ]]
};
polybooljs.difference(T,S) // {   regions: [[
                           //         [ 3.1827730120236866, -14.647299060696893 ],
                           //         [ 3.2790977409099513, -15.096879410975502 ],
                           //         [ 3.2853440594539682, -14.919993494289328 ],
                           //         [ 3.2411990917407074, -14.919993494289326 ],
                           //         [ 3.292779172743269, -14.709442780204576]
                           //     ]],
                           //     inverted: false    }

Here is a graphical representation of T and S:
bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions