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
This page is generated from the comments in src/math/p5.Vector.js . Please feel free to edit it and submit a pull request!