Rotate a vector around the origin.
The target vector.
The amount of rotation to apply in radians.
Error - When a computed component is NaN or non-finite.
rotate({ x: 1, y: 0 }, Math.PI / 2); // -> { x: 6.123233995736766e-17, y: 1 } Copy
rotate({ x: 1, y: 0 }, Math.PI / 2); // -> { x: 6.123233995736766e-17, y: 1 }
Optional
Optional destination object to store the result.
const result = { x: 0, y: 0 };rotate({ x: 1, y: 0 }, Math.PI / 2, result); // result -> { x: 6.123233995736766e-17, y: 1 } Copy
const result = { x: 0, y: 0 };rotate({ x: 1, y: 0 }, Math.PI / 2, result); // result -> { x: 6.123233995736766e-17, y: 1 }
Rotate a vector around the origin.