MCPcopy Index your code
hub / github.com/processing/p5.js / rotate

Method rotate

src/math/p5.Vector.js:2166–2173  ·  view source on GitHub ↗

* Rotates a 2D vector by an 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() , `rotate()` uses * the un

(a)

Source from the content-addressed store, hash-verified

2164 * }
2165 */
2166 rotate(a) {
2167 let newHeading = this.heading() + a;
2168 if (this.isPInst) newHeading = this._toRadians(newHeading);
2169 const mag = this.mag();
2170 this.x = Math.cos(newHeading) * mag;
2171 this.y = Math.sin(newHeading) * mag;
2172 return this;
2173 }
2174
2175 /**
2176 * Calculates the angle between two vectors.

Callers 5

environment.jsFile · 0.45
structure.jsFile · 0.45
webgpu.jsFile · 0.45
webgl.jsFile · 0.45
p5.Vector.jsFile · 0.45

Calls 5

headingMethod · 0.95
magMethod · 0.95
_friendlyErrorMethod · 0.95
copyMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected