Function or value | Description |
|
|
Full Usage:
boundingBox polygon
Parameters:
Polygon2D<'Units, 'Coordinates>
Returns: BoundingBox2D<'Units, 'Coordinates> option
|
![]() ![]() ![]() ![]() ![]() ![]() Get the minimal bounding box containing a given polygon. Returns `None` if the polygon has no vertices.
|
|
|
|
![]() ![]() ![]() ![]() ![]() ![]() Check if a polygon contains a given point. This is an O(n) operation. The polygon can have holes and does not need to be convex.
|
|
![]() ![]() ![]() ![]() ![]() ![]() Build the [convex hull](https://en.wikipedia.org/wiki/Convex_hull) of a list of points. This is an O(n log n) operation.
|
Full Usage:
edges polygon
Parameters:
Polygon2D<'Units, 'Coordinates>
Returns: LineSegment2D<'Units, 'Coordinates> list
|
|
|
![]() ![]() ![]() ![]() ![]() ![]() Get the holes (if any) of a polygon, each defined by a list of vertices. Each list of vertices will be in clockwise order.
|
Full Usage:
loopEdges vertices_
Parameters:
Point2D<'Units, 'Coordinates> list
Returns: LineSegment2D<'Units, 'Coordinates> list
|
|
|
|
|
![]() ![]() ![]() ![]() ![]() ![]() Mirror a polygon across the given axis. The order of the polygon's vertices will be reversed so that the resulting polygon still has its outer vertices in counterclockwise order and its inner vertices in clockwise order.
|
|
![]() ![]() ![]() ![]() ![]() ![]() Get the list of vertices defining the outer loop (border) of a polygon. The vertices will be in counterclockwise order.
|
|
![]() ![]() ![]() ![]() ![]() ![]() Get the perimeter of a polygon (the sum of the lengths of its edges). This includes the outer perimeter and the perimeter of any holes.
|
|
![]() ![]() ![]() ![]() ![]() ![]() Take a polygon considered to be defined in local coordinates relative to a given reference frame, and return that polygon expressed in global coordinates. If the given frame is left-handed, the order of the polygon's vertices will be reversed so that the resulting polygon still has its outer vertices in counterclockwise order and its inner vertices in clockwise order.
|
|
![]() ![]() ![]() ![]() ![]() ![]() Take a polygon defined in global coordinates, and return it expressed in local coordinates relative to a given reference frame. If the given frame is left-handed, the order of the polygon's vertices will be reversed so that the resulting polygon still has its outer vertices in counterclockwise order and its inner vertices in clockwise order.
|
|
|
|
![]() ![]() ![]() ![]() ![]() ![]() Scale a polygon about a given center point by a given scale. If the given scale is negative, the order of the polygon's vertices will be reversed so that the resulting polygon still has its outer vertices in counterclockwise order and its inner vertices in clockwise order.
|
|
![]() ![]() ![]() ![]() ![]() ![]() Construct a polygon without holes from a list of its vertices: let rectangle = Polygon2D.singleLoop [ Point2D.meters 1. 1. Point2D.meters 3. 1. Point2D.meters 3. 2. Point2D.meters 1. 2. ] The last vertex is implicitly considered to be connected back to the first vertex (you do not have to close the polygon explicitly). Vertices should ideally be provided in counterclockwise order; if they are provided in clockwise order they will be reversed.
|
|
|
|
|
Full Usage:
translateIn direction distance polygon
Parameters:
Direction2D<'Coordinates>
distance : Quantity<'Units>
polygon : Polygon2D<'Units, 'Coordinates>
Returns: Polygon2D<'Units, 'Coordinates>
|
|
|
![]() ![]() ![]() ![]() ![]() ![]() Get all vertices of a polygon; this will include vertices from the outer loop of the polygon and all inner loops. The order of the returned vertices is undefined.
|
|
![]() ![]() ![]() ![]() ![]() ![]() Construct a polygon with holes from one outer loop and a list of inner loops. The loops must not touch or intersect each other. let outerLoop = [ Point2D.meters 0. 0. Point2D.meters 3. 0. Point2D.meters 3. 3. Point2D.meters 0. 3. ] let innerLoop = [ Point2D.meters 1. 1. Point2D.meters 1. 2. Point2D.meters 2. 2. Point2D.meters 2. 1. ] let squareWithHole = Polygon2D.withHoles [ innerLoop ] outerLoop As with `Polygon2D.singleLoop`, the last vertex of each loop is considered to be connected back to the first. Vertices of the outer loop should ideally be provided in counterclockwise order and vertices of the inner loops should ideally be provided in clockwise order.
|