Skip to content

Incorrect output for self-intersecting polygon #48

@sergeyvin

Description

@sergeyvin

Brief intro. My original shape boundaries are polylines (arcs + line segments) . Then shapes are split to positive/negative arc segments + polygon. Arc segments are handled separately. Polygon is triangulated by poly2tri.
The problem is sometimes polygon can be self-intersecting because of cutting arc segments. It happens pretty rare, self-intersection check has the same complexity as triangulation so it is faster to try to triangulate and fail rather than check polygon before.
In most cases poly2tri generates exceptions for self-intersecting polygons.

But there are few cases when triangulation completes successfully but there are triangle even of original polygon. There is workaround to check for polygon bbox but would be great if poly2tri can generate exception in this case as well
Recently reproduced it with very simple example - just one arc path and 11 points.
2987.63 2259.05
2987.63 2254.95
2997.62 2254.95
3006.56 2250.48
3019.17 2244.17
3025.48 2231.56
3029.95 2222.62
3029.95 2212.63
3034.05 2212.63
3029.15 2233.39
3008.39 2254.15

bad_triangulation

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