Calculates the distance between two points.
The version of dist()
with four parameters calculates distance in two dimensions.
The version of dist()
with six parameters calculates distance in three dimensions.
Use p5.Vector.dist() to calculate the distance between two p5.Vector objects.
Examples
Syntax
dist(x1, y1, x2, y2)
dist(x1, y1, z1, x2, y2, z2)
dist(v)
Parameters
x1
Number: x-coordinate of the first point.
y1
Number: y-coordinate of the first point.
x2
Number: x-coordinate of the second point.
y2
Number: y-coordinate of the second point.
z1
Number: z-coordinate of the first point.
z2
Number: z-coordinate of the second point.
v
p5.Vector: x, y, and z coordinates of a p5.Vector.
Returns
Number: distance between the two points.
Notice any errors or typos? Please let us know. Please feel free to edit src/math/p5.Vector.js and open a pull request!
Related References
textToContours
Returns an array of arrays of points outlining a string of text written using the font.
textToModel
Converts text into a 3D model that can be rendered in WebGL mode.
textToPaths
Returns a flat array of path commands that describe the outlines of a string of text.
textToPoints
Returns an array of points outlining a string of text written using the font.