The vector of numbers to be normalized.
A new vector that represents the normalized form of the input vector.
normalize([3, 4]); // Returns [0.6, 0.8]
Normalizes a vector of bigints.
The vector of bigints to be normalized.
A new vector that represents the normalized form of the input vector.
normalize([3n, 4n]); // Returns [3n, 4n]
Normalizes a vector of numeric type T.
The function computes the length of the vector and divides each element by the length,
thus normalizing the vector to a length/magnitude of 1 or -1.
The normalization is done based on the provided numeric type (number/bigint or other, with other requiring a Numerical
The numeric type of the elements in the vector. T is inferred and doesn't need to be supplied manually.
The vector to be normalized.
Optional
numerical: Numerical<T>(optional) An instance of Numerical interface for the numeric type T.
A new vector that represents the normalized form of the input vector.
If the vector's type is neither number[] nor bigint[], and no Numerical
normalize([3, 4]); // Returns [0.6, 0.8]
normalize([3n, 4n]); // Returns [3n, 4n]
normalize([3, 4], new Numerical()); // Where Numerical() is an implementation for type T.
Generated using TypeDoc
Normalizes a vector of numbers.