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

Method mag

src/math/p5.Vector.js:1247–1254  ·  view source on GitHub ↗

* Calculates the magnitude (length) of the vector. * * Use mag() to calculate the magnitude of a 2D vector * using components as in `mag(x, y)`. * * @return {Number} magnitude of the vector. * * @example * function setup() { * createCanvas(100, 100

()

Source from the content-addressed store, hash-verified

1245 * }
1246 */
1247 mag() {
1248 let sum = 0;
1249 for (let i = 0; i < this.values.length; i++) {
1250 const component = this.values[i];
1251 sum += component * component;
1252 }
1253 return Math.sqrt(sum);
1254 }
1255
1256 /**
1257 * Calculates the magnitude (length) of the vector squared.

Callers 14

textToModelMethod · 0.95
normalizeMethod · 0.95
setHeadingMethod · 0.95
rotateMethod · 0.95
slerpMethod · 0.95
attractor.jsFile · 0.80
separateMethod · 0.80
liquid.jsFile · 0.80
p5.Camera.jsFile · 0.80
p5.Vector.jsFile · 0.80
calculation.jsFile · 0.80
_getFaceNormalMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected