Normalize a vector to unit length. A zero vector is returned unchanged.
Target can be vec object or array.
Error - When a computed component is NaN or non-finite.
normalize({ x: 0, y: 5 }); // -> { x: 0, y: 1 } Copy
normalize({ x: 0, y: 5 }); // -> { x: 0, y: 1 }
Optional
destination object to store the result.
const result = { x: 0, y: 0 };normalize({ x: 0, y: 5 }, result); // result -> { x: 0, y: 1 } Copy
const result = { x: 0, y: 0 };normalize({ x: 0, y: 5 }, result); // result -> { x: 0, y: 1 }
Normalize a vector to unit length. A zero vector is returned unchanged.