* 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); *
()
| 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. |
no outgoing calls
no test coverage detected