Reference rotate()

rotate()

Rotates a 2D vector by an angle without changing its magnitude.

By convention, the positive x-axis has an angle of 0. Angles increase in the clockwise direction.

If the vector was created with createVector(), rotate() uses the units of the current angleMode().

The static version of rotate(), as in p5.Vector.rotate(v, PI), returns a new p5.Vector object and doesn't change the original.

Examples

Syntax

rotate(angle)
rotate(v, angle, [target])

Parameters

angle
Number:

angle of rotation.

v
p5.Vector:
target
p5.Vector:

The vector to receive the result

Notice any errors or typos? Please let us know. Please feel free to edit src/math/p5.Vector.js and open a pull request!

Related References