class Geometry · Computations

Extremes

Finds the extreme point of a point set: the leftmost, rightmost, topmost, bottommost, closest to or farthest from a point. Top and bottom as on screen: y grows downwards.

Static methods

bottomMoststatic

static bottomMost(points: Sequence<Vector> | VectorsLike, result?: Point | null): Point

Returns the bottom-most point in the provided sequence, using a screen-based coordinate system.

points
The sequence of points to evaluate.
result optional
An optional existing point instance to store the result in, or null to create a new one.

Returns The point with the largest Y-coordinate in the sequence.

closestTostatic

static closestTo(points: Sequence<Vector> | VectorsLike, reference: Point | VectorLike, result?: Point | null): Point

Returns the point in a sequence that is closest to the given reference point.

points
The sequence of points to search.
reference
The reference point to measure distances from.
result optional
An optional existing point instance to store the result in, or null to create a new one.

Returns The point in points nearest to reference.

extremestatic

static extreme(points: Sequence<Vector> | VectorsLike, pointComparison: (x: Point, y: Point) => number, result?: Point | null): Point

Returns the extremal point in a sequence according to the supplied comparison. The comparison should return a negative value when its first argument is considered more extreme than its second.

points
The sequence of points to evaluate.
pointComparison
A comparison delegate that defines the ordering. A return value less than zero means the first argument is more extreme.
result optional
An optional existing point instance to store the result in, or null to create a new one.

Returns The most extreme point in points according to pointComparison; the origin if points is empty (this holds for all methods of this class).

farthestFromstatic

static farthestFrom(points: Sequence<Vector> | VectorsLike, reference: Point | VectorLike, result?: Point | null): Point

Returns the point in a sequence that is farthest from the given reference point.

points
The sequence of points to search.
reference
The reference point to measure distances from.
result optional
An optional existing point instance to store the result in, or null to create a new one.

Returns The point in points farthest from reference.

leftMoststatic

static leftMost(points: Sequence<Vector> | VectorsLike, result?: Point | null): Point

Returns the left-most point in the provided sequence.

points
The sequence of points to evaluate.
result optional
An optional existing point instance to store the result in, or null to create a new one.

Returns The point with the smallest X-coordinate in the sequence.

rightMoststatic

static rightMost(points: Sequence<Vector> | VectorsLike, result?: Point | null): Point

Returns the right-most point in the provided sequence.

points
The sequence of points to evaluate.
result optional
An optional existing point instance to store the result in, or null to create a new one.

Returns The point with the largest X-coordinate in the sequence.

topMoststatic

static topMost(points: Sequence<Vector> | VectorsLike, result?: Point | null): Point

Returns the top-most point in the provided sequence, using a screen-based coordinate system.

points
The sequence of points to evaluate.
result optional
An optional existing point instance to store the result in, or null to create a new one.

Returns The point with the smallest Y-coordinate in the sequence.