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

Method setMag

src/math/p5.Vector.js:1835–1837  ·  view source on GitHub ↗

* Sets a vector's magnitude to a given value. * * The static version of `setMag()`, as in `p5.Vector.setMag(v, 10)`, returns * a new p5.Vector object and doesn't change the * original. * * @param {Number} len new length for this vector. * @chainable

(n)

Source from the content-addressed store, hash-verified

1833 * }
1834 */
1835 setMag(n) {
1836 return this.normalize().mult(n);
1837 }
1838
1839 /**
1840 * Calculates the angle a 2D vector makes with the positive x-axis.

Callers 3

constructorMethod · 0.80
attractedMethod · 0.80
p5.Vector.jsFile · 0.80

Calls 5

normalizeMethod · 0.95
_friendlyErrorMethod · 0.95
multMethod · 0.45
copyMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected