Represents a polygon.
0.1.0
.Static methods
staticinlinegetMinkowskiDiff(points1:Array<Point>, points2:Array<Point>):Array<Point>
Returns the minkowski difference between two polygons.
Here are some nice properties of the minkowski difference:
- If it contains the origin, that means the two shapes intersects.
- The minimum distance between the origin and the points of the minkowski difference
is the distance between the two shapes.
Parameters:
points1 | An array of |
---|---|
points2 | An array of |
Returns:
An array of h2d.col.Point
defining the shape of the minkowski difference.
staticinlinemakeCircle(radius:Float, cx:Float = 0, cy:Float = 0, nSegments:Int = 0):Polygon
Creates a polygon in the shape of a circle.
Parameters:
radius | The radius of the circle. |
---|---|
cx | The x position of the center of the circle. |
cy | The y position of the center of the circle. |
nSegments | The number of segments of the circle. The minimum is |
Returns:
An nb.shape.Polygon
instance.
Constructor
new(points:Polygon, ?parent:Object)
Creates an nb.shape.Polygon
instance.
Parameters:
points | An array of |
---|---|
parent | The parent object of this instance. |
Variables
read onlypoints:Polygon
The associated h2d.col.Polygon
instance, which is an abstract type defined over an Array<h2d.col.Point>
.
See also:
read onlyrightSideFaceInside:Bool = false
Whether the right side of the segments of the polygon face inwards.
Methods
getEdgePoint(ray:Ray, ?outSeg:Segment):Null<Point>
Gets a point on the edge of this polygon.
Parameters:
ray | An |
---|---|
outSeg | An |
Returns:
An h2d.col.Point
instance. The first point on a segment of this polygon intersecting with ray
.
getFarthestPoints(vector:Point):Array<Point>
Returns the farthest points in the direction defined by vector
.
getFarthestPointsFrom(fromCentroid:Bool = true):Array<Point>
Returns the farthest points of this shape from its center or centroid.
Parameters:
fromCentroid | If |
---|
Returns:
An array of h2d.col.Point
. Only the points that are the farthest are returned,
not all the points of this shape from the farthest to the closest.
getSegmentsIntersections(a:Array<Segment>):Array<Segment>
Returns the segments of this polygon intersecting with the given segments a
.
toSegments():Segments
Returns the segments of this instance.
h2d.col.Segments
is an abstract type
defined over Array<h2d.col.Segment>
.
updateFields():Void
Updates fields related to this shape's current attributes, as deduced from points
.