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

Method magSq

src/math/p5.Vector.js:1284–1291  ·  view source on GitHub ↗

* Calculates the magnitude (length) of the vector squared. * * @return {Number} squared magnitude of the vector. * @example * function setup() { * createCanvas(100, 100); * * background(200); * * // Create a p5.Vector object. * let p = createVector(30, 40); *

()

Source from the content-addressed store, hash-verified

1282 * }
1283 */
1284 magSq() {
1285 let sum = 0;
1286 for (let i = 0; i < this.values.length; i++) {
1287 const component = this.values[i];
1288 sum += component * component;
1289 }
1290 return sum;
1291 }
1292
1293 /**
1294 * Calculates the dot product of two vectors.

Callers 8

limitMethod · 0.95
angleBetweenMethod · 0.95
attractedMethod · 0.80
p5.Vector.jsFile · 0.80
addImmediateMethod · 0.80
_edgesToVerticesMethod · 0.80
slerpMethod · 0.80
interactionFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected