Measures the angle between two vectors in degrees, always between 0 and 180.
The direction of turning is not considered; use signedAngleBetween for that.
Example: [1,0,0] and [0,1,0] -> 90
The two vectors
Angle in degrees
Measures the signed angle from the first 2D vector to the second, in degrees from -180 to 180.
Only the first two entries of each vector are used; a positive angle turns counter-clockwise. Example: [1,0] to [0,1] -> 90, [0,1] to [1,0] -> -90
The two 2D vectors
Signed angle in degrees
Measures the angle from the first vector to the second, turning around a reference direction, in degrees from 0 to 360.
The turn is counter-clockwise when the reference vector points toward you. Example: [1,0,0] to [0,0,-1] around [0,1,0] -> 90
The two vectors and the reference direction to turn around
Angle in degrees from 0 to 360
Measures the angle from the first vector to the second, turning around a reference direction, in degrees from 0 to 360.
The turn is counter-clockwise when the reference vector points toward you: a clockwise turn of 30 degrees reads as 330. Example: [1,0,0] to [0,0,-1] around [0,1,0] -> 90
The two vectors and the reference direction to turn around
Angle in degrees from 0 to 360
Computes the cross product of two 3D vectors: a vector at right angles to both.
Its direction follows the right-hand rule and its length is the area of the parallelogram the two vectors span. Example: [1,0,0] x [0,1,0] -> [0,0,1]
The two 3D vectors
The vector perpendicular to both
Divides every entry of a vector by one number.
Example: [10,20,30] / 2 -> [5,10,15]
The vector and the number to divide by
The divided vector
Subtracts the first value of a vector from its last, which for a sorted list is its range.
Example: [1,3,5,9] -> 8
The vector
Last value minus first value
Computes the dot product of two vectors: the sum of the products of matching entries.
It is 0 for vectors at right angles and, for unit vectors, the cosine of the angle between them. Example: [1,2,3] and [4,5,6] -> 32
The two vectors
The dot product
Multiplies every entry of a vector by one number.
Example: [2,3,4] x 5 -> [10,15,20]
The vector and the number to multiply by
The scaled vector
Flips the sign of every entry, so the vector points the opposite way.
Example: [5,-3,2] -> [-5,3,-2]
The vector to flip
The negated vector
Computes the squared length of a vector, which avoids the square root when only comparing lengths.
Example: [3,4,0] -> 25
The vector
The squared length
Computes the length of a vector.
Example: [3,4,0] -> 5, [1,0,0] -> 1
The vector
The length in model units
Scales a 3D vector to length 1 while keeping its direction.
A vector shorter than 1e-8 has no direction to keep, so the result is undefined. Example: [3,4,0] -> [0.6,0.8,0]
The 3D vector to normalize
The unit vector, or undefined for a zero-length input
Finds the point at a given distance from a start point along a direction.
The direction is used as given, so a direction of length 2 travels twice the distance. Example: start [0,0,0], direction [1,0,0], distance 5 -> [5,0,0]
The start point, the direction and the distance
The point on the ray
Subtracts the second vector from the first, entry by entry.
Example: [10,20,30] - [1,2,3] -> [9,18,27]
The vector to subtract from and the vector to subtract
The vector of differences
Adds up all values of a vector into one number.
Example: [1,2,3,4] -> 10
The vector to add up
The total
Computes the squared length of a 3D vector, which avoids the square root when only comparing lengths.
Example: [3,4,0] -> 25
The 3D vector
The squared length
Computes the length of a 3D vector.
Example: [3,4,0] -> 5
The 3D vector
The length in model units
Builds a 3D vector from its x, y and z values.
Example: x=1, y=2, z=3 -> [1,2,3]
The three values
The vector [x, y, z]
Builds a 2D vector from its x and y values.
Example: x=3, y=4 -> [3,4]
The two values
The vector [x, y]
Lists the whole numbers from 0 up to, but not including, max.
Example: max=5 -> [0,1,2,3,4]
The end of the range, which is left out
The numbers from 0 to max - 1
Lists the numbers from min to max, stepping by step; max is included when a step
lands on it.
Example: min=0, max=10, step=2 -> [0,2,4,6,8,10]
The start, the end and the step
The numbers in the span
Lists nrItems numbers from min to max spaced by an easing curve, so they bunch up at
one end or both.
With intervals on, the result holds the gaps between neighbors instead of the values
themselves.
Example: min=0, max=100, nrItems=5, ease='easeInQuad' -> [0, 6.25, 25, 56.25, 100]
The start, the end, the number of items, the easing and whether to return the gaps
The eased numbers, or the gaps between them
Lists nrItems evenly spaced numbers from min to max, both included.
Example: min=0, max=10, nrItems=5 -> [0, 2.5, 5, 7.5, 10]
The start, the end and the number of items
The evenly spaced numbers
Turns a list of number strings into numbers.
A string that is not a number becomes NaN. Example: ['1', '2.5', '3'] -> [1, 2.5, 3]
The strings to parse
The numbers
Computes the squared distance between two vectors, which avoids the square root when only comparing distances.
Example: [0,0,0] to [3,4,0] -> 25
The two vectors
The squared distance
Computes the straight-line distance between two vectors.
Example: [0,0,0] to [3,4,0] -> 5
The two vectors
The distance in model units
Blends two vectors linearly by a fraction.
fraction is the share of first: 1 gives first, 0 gives second, 0.5 the midpoint.
Example: [0,0,0] and [10,10,10] at 0.5 -> [5,5,5]
The two vectors and the fraction of the first
The blended vector
Finds the largest value in a vector.
Example: [3, 7, 2, 9, 1] -> 9
The vector
The largest entry
Finds the smallest value in a vector.
Example: [3, 7, 2, 9, 1] -> 1
The vector
The smallest entry
Removes every repeated vector from a list, keeping the first occurrence of each.
Two vectors count as the same when every entry differs by less than tolerance.
Example: [[1,2,3], [4,5,6], [1,2,3], [7,8,9]] -> [[1,2,3], [4,5,6], [7,8,9]]
Vectors to filter and the tolerance
The vectors without repeats, in their original order
Removes a vector when it repeats the one right before it; the same vector further away is kept.
With checkFirstAndLast on, a last vector that repeats the first is dropped too, which
closes a loop of points cleanly. Entries within tolerance of each other count as equal.
Example: [[1,2], [1,2], [3,4], [1,2]] -> [[1,2], [3,4], [1,2]]
Vectors to filter, whether to compare the first and last, and the tolerance
The vectors without consecutive repeats
Adds a list of vectors together entry by entry into one vector.
The result has as many entries as the first vector. Example: [[1,2,3], [4,5,6], [7,8,9]] -> [12,15,18]
Vectors to add
The vector of sums
Adds two vectors entry by entry.
Example: [1,2,3] + [4,5,6] -> [5,7,9]
The two vectors to add
The vector of sums
Tells whether every value in a list of booleans is true.
Example: [true, true, true] -> true, [true, false, true] -> false
The booleans to check
True when no entry is false
Tells whether two vectors are the same within a tolerance, entry by entry.
Vectors of different length are never the same. Example: [1,2,3] and [1.0001,2.0001,3.0001] with tolerance 0.001 -> true
The two vectors and the tolerance
True when every entry differs by less than the tolerance
Marks which entries of a vector are finite numbers.
Example: [1, 2, Infinity, 3] -> [true, true, false, true]
The vector to check
One boolean per entry, true when it is finite
Tells whether a vector has no length, that is, every entry is exactly 0.
Example: [0,0,0] -> true, [0,0,0.001] -> false
The vector to check
True when the length is 0
Vector maths on plain number arrays. A vector is an array of numbers; in 3D it is
[x, y, z]with Y pointing up, the same shape as a point, so the two can be passed to each other's methods. Every method returns a new array or a number and never changes its inputs. Angles are in degrees.