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
Number:

angle of rotation.

This page is generated from the comments in src/math/p5.Vector.js . Please feel free to edit it and submit a pull request!

Related References