An abstract over the list of Segments. Alternative representation of a polygon.

Segments must be connected to form a complete polygonal shape. Provides a more efficient distance calculus.

See also:


@:implread onlylength:Int

The amount of segments in the polygon.

@:implread onlysegments:Array<Segment>

The underlying Array of segments.


@:implcontainsPoint(p:Point, isConvex:Bool):Bool

Tests if Point p is inside this Segments.



The Point to test against.


Use simplified collision test suited for convex polygons. Results are undefined if polygon is concave. Note: Currently only convex check is implemented and using non-convex test results in an exception.


Returns distance from the Segments to the Point p.


Returns squared distance from the Segments to the Point p.


Projects Point p onto closest Segment in Segments and returns new Point with projected position.


Converts this Segments to a Polygon.