Skip to content

Zero length line segments ruin Polygon2D objects #37

@zostay

Description

@zostay

I'm not really sure this is a bug, but I recently discovered that if you build a polygon from a set of points, you need to be careful to make sure that no consecutive points are equal. This results in a 0 length line segment and causes the SDF code to fail. It will either end up finding no object at all or it will find a series of points that evaluate to NaN coordinates.

I was working on extruding objects from some dirty polygon data that included such. Also my manipulation code expects a closed polygon to be represented with the first and last point being equal. So, I had to make sure to write my code such that the last point is skipped and with code to guard against 0 length segments.

It might be nice to add those the Polygon2D constructor, or maybe just add a note in the docs about the problem.

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