Reference setHeading()

setHeading()

Rotates a 2D vector to a specific 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(), setHeading() uses the units of the current angleMode().

Examples

Syntax

setHeading(angle)

Parameters

angle

angle of rotation.

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