class Geometry · Computations

ConvexHulls

Sections of the convex hull of a point set: the upper, lower, left and right chain, or the part between two start points.

Static methods

bottomSectionstatic

static bottomSection(points: Sequence<Vector> | VectorsLike, result?: Polyline | null): Polyline

Returns the lower section of the convex hull of a set of points as a polyline.

points
The input set of points.
result optional
Optional Polyline to write the result into; it is returned. Without it, a new Polyline is returned.

Returns A polyline representing the bottom section of the convex hull.

bottomStartstatic

static bottomStart(points: Sequence<Vector> | VectorsLike, result?: Polygon | null): Polygon

Returns the convex hull with vertices ordered such that the first point is the bottom-most point.

points
The input set of points.
result optional
Optional Polygon to write the result into; it is returned. Without it, a new Polygon is returned.

Returns The convex hull polygon starting from the bottom-most point. No points give an empty polygon, a single point gives a polygon with that point.

leftSectionstatic

static leftSection(points: Sequence<Vector> | VectorsLike, result?: Polyline | null): Polyline

Returns the left section of the convex hull of a set of points as a polyline.

points
The input set of points.
result optional
Optional Polyline to write the result into; it is returned. Without it, a new Polyline is returned.

Returns A polyline representing the left section of the convex hull.

leftStartstatic

static leftStart(points: Sequence<Vector> | VectorsLike, result?: Polygon | null): Polygon

Returns the convex hull with vertices ordered such that the first point is the left-most point.

points
The input set of points.
result optional
Optional Polygon to write the result into; it is returned. Without it, a new Polygon is returned.

Returns The convex hull polygon starting from the left-most point.

rightSectionstatic

static rightSection(points: Sequence<Vector> | VectorsLike, result?: Polyline | null): Polyline

Returns the right section of the convex hull of a set of points as a polyline.

points
The input set of points.
result optional
Optional Polyline to write the result into; it is returned. Without it, a new Polyline is returned.

Returns A polyline representing the right section of the convex hull.

rightStartstatic

static rightStart(points: Sequence<Vector> | VectorsLike, result?: Polygon | null): Polygon

Returns the convex hull with vertices ordered such that the first point is the right-most point.

points
The input set of points.
result optional
Optional Polygon to write the result into; it is returned. Without it, a new Polygon is returned.

Returns The convex hull polygon starting from the right-most point.

sectionstatic

static section(points: Sequence<Vector> | VectorsLike, from: Vector | VectorLike, to: Vector | VectorLike, clockwise: Bool | BoolLike, result?: Polyline | null): Polyline

Returns a part of the convex hull's boundary between two directions: from where the ray from the hull's center (its centroid) in from meets the boundary to where the ray in to does, e.g. ConvexHulls.section(points, [-1, 0], [1, 0], true) is the upper half on screen.

Both ends are new vertices where the rays cross an edge (no new vertex where a ray meets a vertex). With clockwise the section runs clockwise on screen (the way of topStart), else the other way round. Equal directions give the whole boundary as a closed polyline (its last point is its first). Hull points as in topStart; points that are not finite are skipped. No points, a zero direction or one that is not finite give an empty polyline; one point gives that point. If all points lie on a line, the hull is its two ends, and each direction picks the end farther in it.

points
The input set of points.
from
The direction from the center where the section starts.
to
The direction from the center where the section ends.
clockwise
Whether the section runs clockwise on screen.
result optional
Optional Polyline to write the result into; it is returned. Without it, a new Polyline is returned.

Returns The section as a polyline.

startAtstatic

static startAt(points: Sequence<Vector> | VectorsLike, direction: Vector | VectorLike, clockwise: Bool | BoolLike, result?: Polygon | null): Polygon

Returns the convex hull starting in a direction: the first point is where the ray from the hull's center (its centroid) in direction meets the boundary, e.g. ConvexHulls.startAt(points, [0, -1], true) starts straight above the center on screen.

The first point is a new vertex where the ray crosses an edge (no new vertex where it meets a vertex). With clockwise the hull runs clockwise on screen, as in topStart, else the other way round. Hull points as in topStart; points that are not finite are skipped. No points, a zero direction or one that is not finite give an empty polygon; one point gives that point. If all points lie on a line, the hull is its two ends and the first point is the end farther in the direction.

points
The input set of points.
direction
The direction from the center in which the hull starts.
clockwise
Whether the hull runs clockwise on screen.
result optional
Optional Polygon to write the result into; it is returned. Without it, a new Polygon is returned.

Returns The convex hull polygon starting in the direction.

topSectionstatic

static topSection(points: Sequence<Vector> | VectorsLike, result?: Polyline | null): Polyline

Returns the top section of the convex hull of a set of points as a polyline.

points
The input set of points.
result optional
Optional Polyline to write the result into; it is returned. Without it, a new Polyline is returned.

Returns A polyline representing the top section of the convex hull.

topStartstatic

static topStart(points: Sequence<Vector> | VectorsLike, result?: Polygon | null): Polygon

Returns the convex hull with vertices ordered such that the first point is the top-most point.

points
The input set of points.
result optional
Optional Polygon to write the result into; it is returned. Without it, a new Polygon is returned.

Returns The convex hull polygon starting from the top-most point.