Home > @josh-brown/vector > normalize
Returns a vector with the same direction as the input v, but with a Euclidean norm of 1
Signature:
export declare function normalize<S>(v: Vector<S>): Vector<S> | undefined;|
Parameter |
Type |
Description |
|---|---|---|
|
v |
Vector<S> |
The vector to normalize |
Returns:
Vector<S> | undefined
const v = vec(3, 4);
const normalized = normalize(v); // [ 0.6, 0.8 ]