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 v1.dist(v2)
.
Use dist() to calculate the distance between points using coordinates as in dist(x1, y1, x2, y2)
.
Examples
Syntax
dist(v)
dist(v1, v2)
Parameters
v
p5.Vector:
x, y, and z coordinates of a p5.Vector.
v1
p5.Vector:
The first p5.Vector
v2
p5.Vector:
The second p5.Vector
Returns
Number: distance.
This page is generated from the comments in src/math/p5.Vector.js . Please feel free to edit it and submit a pull request!