Reference heading()

heading()

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()

Parameters

Returns

Number: angle of rotation.

Related References