vec2-fn
    Preparing search index...

    Function rotate

    • Rotate a vector around the origin.

      Type Parameters

      Parameters

      • target: T

        The target vector.

      • angle: number

        The amount of rotation to apply in radians.

      Returns T

      • A reference to the modified target vector.

      Error - When a computed component is NaN or non-finite.

      rotate({ x: 1, y: 0 }, Math.PI / 2); // -> { x: 6.123233995736766e-17, y: 1 }
      
    • Rotate a vector around the origin.

      Type Parameters

      Parameters

      • target: Vec2Param

        The target vector.

      • angle: number

        The amount of rotation to apply in radians.

      • Optionaldest: D

        Optional destination object to store the result.

      Returns D

      • A reference to the modified destination vector.

      Error - When a computed component is NaN or non-finite.

      const result = { x: 0, y: 0 };
      rotate({ x: 1, y: 0 }, Math.PI / 2, result); // result -> { x: 6.123233995736766e-17, y: 1 }