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.
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 using interpolation.
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
- compare - Compares two points by xyz values
- compareByX / compareByY / compareByZ - Compares two points only by x/y/z value, ignoring the other fields.
- distance - Distance between two points
- distanceToCenter - Distance to center of a shape
- distanceToExterior - Distance to exterior of a shape
- findMinimum - find the ‘minimum’ within a set of points using provided function
- isEqual - Checks if two points have same value
- leftmost - return the left-most of the provided points
- rightmost - return the right-most of the provided points
- progressBetween - progress between two waypoints
- relation - returns a function to compute Type PointRelationResult
- withinRange -checks if point is within a given range of another
Conversions/creating
- from - create from
[x,y]
,[x,y,z]
- fromNumbers - create from
x, y
- random / random3d - create random point
- toArray - returns
[x,y]
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
orPoints.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
orPoints.Placeholder3d
.