MCPcopy
hub / github.com/processing/p5.js / heading

Method heading

src/math/p5.Vector.js:1932–1936  ·  view source on GitHub ↗

* 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

()

Source from the content-addressed store, hash-verified

1930 * }
1931 */
1932 heading() {
1933 const h = Math.atan2(this.y, this.x);
1934 if (this.isPInst) return this._fromRadians(h);
1935 return h;
1936 }
1937
1938 /**
1939 * Rotates a 2D vector to a specific angle without changing its magnitude.

Callers 3

rotateMethod · 0.95
renderMethod · 0.80
p5.Vector.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected