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.
示例
语法
heading()
heading(v)
参数
v
p5.Vector:
the vector to find the angle of
Returns
Number: 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!