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

Method dist

src/math/p5.Vector.js:1556–1564  ·  view source on GitHub ↗

* Calculates the distance between two points represented by vectors. * * A point's coordinates can be represented by the components of a vector * that extends from the origin to the point. * * The static version of `dist()`, as in `p5.Vector.dist(v1, v2)`, is the same * as calling

(v)

Source from the content-addressed store, hash-verified

1554 * }
1555 */
1556 dist(v) {
1557 const minDimension = prioritizeSmallerDimension(this.dimensions, v.values);
1558 let sum = 0;
1559 for (let i = 0; i < minDimension; i++) {
1560 const component = this.values[i] - v.values[i];
1561 sum += component * component;
1562 }
1563 return Math.sqrt(sum);
1564 }
1565
1566 /**
1567 * Scales the components of a <a href="#/p5.Vector">p5.Vector</a> object so

Callers 9

drawFunction · 0.80
separateMethod · 0.80
alignMethod · 0.80
cohesionMethod · 0.80
p5.Vector.jsFile · 0.80
calculation.jsFile · 0.80
slerpMethod · 0.80
subdivideMethod · 0.80
polylineLengthFunction · 0.80

Calls 1

Tested by

no test coverage detected