Skip to content

Point

Module Geometry.Points

In ixfx, a Point is at least an x and y coordinate. Some - but very few - functions also work with the z property, if provided.

type Point = {
x: number
y: number
z?: number
}

Once you have that there are a bunch of functions to help you work with points.

  • angleRadian - compute angle, in radian
  • bbox - compute bounding box for provided points
  • centroid - centroid of a set of points
  • convexHull - set of points which enclose a larger set of points
  • interpolate - return relative point between two points

Manipulating

  • clamp - clamp x, y & z to provided min/max
  • clampMagnitude - clamp magnitude
  • normalise - normalise to unit vector
  • normaliseByRect - normalise x & y by given width & height
  • pipeline - perform a series of operations on a Point
  • project - project from origin a given distance and angle
  • reduce - for a given set of points, reduce x & y value separately
  • rotate - rotates a single point by given angle and pivot point
  • rotatePointArray - as above, but for many points
  • round - round x & y values to given number of digits
  • toIntegerValues - round x & y values to integer values
  • wrap - given a point, and a min max, ‘wraps’ the values so it stays within bounds.

Comparison with other points/shapes

Conversions/creating

Math

  • abs - apply Math.abs to xyz
  • apply - apply a function to xyz coordinates
  • divide - divide xyz values
  • divider - function that divides
  • dotProduct
  • multiply - multiply xyz by another point or rectangle (using its width/height)
  • multiplyScalar - multiply xyz by same value
  • subtract - subtract xyz values of one point by another
  • sum - add xyz values of one point with another
  • invert - invert one or more axis
  • quantiseEvery - quantise xyz values

Etc

  • isEmpty - true if Point is empty (both x & y are 0). Get an empty point with Points.Empty or Points.Empty3d.

  • isNaN - true if x or y properties are NaN

  • isPlaceholder - true if both x & y properties are NaN. Get a placeholder point with Points.Placeholder or Points.Placeholder3d.