Skip to content

Simple intersection fails #97

@shehzan10

Description

@shehzan10

The following code fails intersection and returns an empty array:

const poly1 = [[
    [0, 0],
    [1, 0],
    [1, 1],
    [0, 1],
    [0, 0]
]];

const poly2 = [[
    [0.5, 0.0],
    [0.6, 0.5],
    [0.7, 0.5],
    [0.5, 0.0]
]];
const intersectionPolygon = martinezPolygonClipping.intersection(poly1, poly2);

In the above case, the poly2 can be interpreted as "leaning right", with exactly 1 vertex at the southern edge.

However, when running with poly2 "leaning left", this passes.

const poly2 = [[
    [0.5, 0.0],
    [0.4, 0.5],
    [0.3, 0.5],
    [0.5, 0.0]
]];

It also passes when the vertex is not on the southern edge.

const poly2 = [[
    [0.5, 0.00001], // Both +0.00001 and -0.0001 pass
    [0.6, 0.5],
    [0.7, 0.5],
    [0.5, 0.00001]
]];

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions