math.dist

Full name
math.dist
Library
math
Syntax

math.dist(p, q)

Description

The math.dist function returns the Euclidean distance between the two indicated points. These must be defined by a sequence (or iterable) of coordinates and must have the same dimension.

Parameters
  • p, q: points to be considered when calculating the distance.
Result

The math.dist function returns a real number.

Examples

We can use this function in one-dimensional space:

math.dist([3], [7])
4.0

...or on a plane:

math.dist([0, 0], [1, 1])
1.4142135623730951

...or in a three-dimensional space:

math.dist([0, 0, 0], [1, 1, 1])
1.7320508075688772

...or in a space of greater dimensionality.

Submitted by admin on Sat, 02/06/2021 - 08:50