Calculates the angle a 2D vector makes with the positive x-axis.
By convention, the positive x-axis has an angle of 0. Angles increase in the clockwise direction.
If the vector was created with createVector(), heading()
returns angles in the units of the current angleMode().
The static version of heading()
, as in p5.Vector.heading(v)
, works the same way.
Examples
Syntax
heading()
heading(v)
Parameters
v
p5.Vector:
the vector to find the angle of
Notice any errors or typos? Please let us know. Please feel free to edit src/math/p5.Vector.js and open a pull request!