ixfx
    Preparing search index...

    Namespace Points

    Functions

    abs

    Returns a point with Math.abs applied to x,y and z if present.

    angleRadian

    Returns the angle in radians between a and b.

    angleRadianCircle

    Returns the angle between point(s) using a radian circle system.

    apply

    Applies fn on x,y & z (if present) fields, returning all other fields as well

    averager

    Uses =@ixfx/numbers#movingAverageLight to keep track of average x, y and z values.

    // Create averager
    const averager = Points.averager(`moving-average-light`
    bbox

    Returns the minimum rectangle that can enclose all provided points

    bbox3d
    centroid

    Calculates the centroid of a set of points Undefined values are skipped over.

    clamp

    Clamps a point to be between min and max (0 & 1 by default)

    clampMagnitude

    Clamps the magnitude of a point. This is useful when using a Point as a vector, to limit forces.

    compare

    Returns -2 if both x & y of a is less than b Returns -1 if either x/y of a is less than b

    compareByX

    Compares points based on x value. Y value is ignored.

    compareByY

    Compares points based on Y value. X value is ignored. Returns values:

    • 0: If a.y === b.y
    • 1: A is below B (ie. a.y > b.y)
    • -1: A is above B (ie. a.y < b.y)
    compareByZ

    Compares points based on Z value. XY values are ignored. Returns values:

    • 0: If a.z === b.z
    • 1: A is below B (ie. a.z > b.z)
    • -1: A is above B (ie. a.z < b.z)
    convexHull

    Simple convex hull impementation. Returns a set of points which enclose pts.

    distance

    Calculate distance between two points. If both points have a z property, the distance is 3D distance is calculated. If only one point has a z, it is ignored.

    distanceToCenter

    Returns the distance from point a to the center of shape.

    distanceToExterior

    Returns the distance from point a to the exterior of shape.

    divide

    Returns a Point with the x,y,z values of two points divide (a/b).

    divider

    Returns a function that divides a point:

    dotProduct
    findMinimum

    Returns the 'minimum' point from an array of points, using a comparison function.

    from

    Returns a point from two or three coordinates or an array of [x,y] or [x,y,z].

    fromNumbers

    Returns an array of points from an array of numbers.

    fromString

    Parses a point as a string, in the form 'x,y' or 'x,y,z'. eg '10,15' will be returned as { x: 10, y: 15 }.

    getTwoPointParameters
    guard

    Throws an error if point is invalid

    guardNonZeroPoint

    Throws if parameter is not a valid point, or either x or y is 0

    interpolate

    Returns a relative point between two points.

    invert

    Inverts one or more axis of a point

    isEmpty

    Returns true if both xy (and z, if present) are 0. Use Points.Empty to return an empty point.

    isEqual

    Returns true if the points have identical values

    isNaN

    Returns true if either x, y, z isNaN.

    isNull

    Returns true if xy (and z, if present) are null.

    isPlaceholder

    Returns true if point is a placeholder, where xy (and z, if present) are NaN.

    isPoint

    Returns true if p has x & y properties. Returns false if p is undefined, null or does not contain properties. Use isPoint3d to check further check for z.

    isPoint3d

    Returns true if p has x, y, & z properties. Returns false if p is undefined, null or does not contain properties.

    leftmost

    Returns the left-most of the provided points.

    multiply

    Returns a Point with the x,y,z values of two points multiply (a/b).

    multiplyScalar

    Multiplies all components by v. Existing properties of pt are maintained.

    normalise

    Normalise point as a unit vector.

    normaliseByRect

    Normalises a point so it is on a 0..1 scale

    pipeline

    Returns a pipeline function that takes a point to be transformed through a series of functions

    // Create pipeline
    const p = Points.pipeline(Points.normalise, Points.invert
    pipelineApply

    Runs a sequential series of functions on pt. The output from one feeding into the next.

    progressBetween

    Computes the progress between two waypoints, given position.

    project

    Project origin by distance and angle (radians).

    quantiseEvery

    Quantises a point.

    random

    Returns a random 2D point on a 0..1 scale.

    random3d

    Returns a random 3D point on a 0..1 scale.

    reduce

    Reduces over points, treating x and y separately.

    relation

    Tracks the relation between two points.

    rightmost

    Returns the right-most of the provided points.

    rotate

    Rotate a single point by a given amount in radians

    rotatePointArray
    round

    Round the point's x and y to given number of digits

    subtract

    Returns a Point with the x,y,z values of two points subtracted (a-b).

    sum

    Returns a Point with the x,y,z values of two points added.

    to2d

    Returns a copy of pt with z field omitted. If it didn't have one to begin within, a copy is still returned.

    to3d

    Returns a copy of pt with a z field set. Defaults to a z value of 0.

    toArray

    Returns point as an array in the form [x,y]. This can be useful for some libraries that expect points in array form.

    toIntegerValues

    Returns a point with rounded x,y coordinates. By default uses Math.round to round.

    toString

    Returns a human-friendly string representation (x, y). If precision is supplied, this will be the number of significant digits.

    withinRange

    Returns true if two points are within a specified range on both axes.

    wrap

    Wraps a point to be within ptMin and ptMax. Note that max values are exclusive, meaning the return value will always be one less.

    References

    PointsTracker → PointsTracker
    PointTrack → PointTrack
    PointTracker → PointTracker
    PointTrackerResults → PointTrackerResults

    Type Aliases

    Point

    A point, consisting of x, y and maybe z fields.

    Point3d
    Point3dApplyFn
    PointApplyFn
    PointAverageKinds
    PointAverager
    PointRelation
    PointRelationResult

    Variables

    Empty

    An empty point of { x: 0, y: 0 }.

    Empty3d

    An empty Point of { x: 0, y: 0, z: 0} Use isEmpty to check if a point is empty. Use Empty to get an empty point without z.

    Placeholder

    Placeholder point: { x: NaN, y: NaN } Use isPlaceholder to check if a point is a placeholder. Use Placeholder3d get a point with z property.

    Placeholder3d

    Placeholder point: {x: NaN, y:NaN, z:NaN } Use isPlaceholder to check if a point is a placeholder. Use Placeholder to get a point without z property.

    Unit

    Returns { x:1, y:1 }

    Unit3d

    Returns { x:1,y:1,z:1 }