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): PointReturns the bottom-most point in the provided sequence, using a screen-based coordinate system.
points- The sequence of points to evaluate.
resultoptional- An optional existing point instance to store the result in, or
nullto 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): PointReturns 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.
resultoptional- An optional existing point instance to store the result in, or
nullto 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): PointReturns 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.
resultoptional- An optional existing point instance to store the result in, or
nullto 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): PointReturns 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.
resultoptional- An optional existing point instance to store the result in, or
nullto create a new one.
Returns The point in points farthest from reference.
leftMoststatic
static leftMost(points: Sequence<Vector> | VectorsLike, result?: Point | null): PointReturns the left-most point in the provided sequence.
points- The sequence of points to evaluate.
resultoptional- An optional existing point instance to store the result in, or
nullto 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): PointReturns the right-most point in the provided sequence.
points- The sequence of points to evaluate.
resultoptional- An optional existing point instance to store the result in, or
nullto 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): PointReturns the top-most point in the provided sequence, using a screen-based coordinate system.
points- The sequence of points to evaluate.
resultoptional- An optional existing point instance to store the result in, or
nullto create a new one.
Returns The point with the smallest Y-coordinate in the sequence.
