Reference dist()

dist()

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)

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.

Returns

Number: distance between the two points.
Notice any errors or typos? Please let us know. Please feel free to edit src/math/calculation.js and open a pull request!

Related References