* 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)
| 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 |
no test coverage detected