Skip to content

Function: distance()

ts
function distance(a, b): number;

Euclidean distance between two coordinate vectors (2D, 3D, or same length). 两点欧氏距离(坐标数组长度须相同,支持 2D/3D 等)。

Parameters

ParameterTypeDescription
anumber[]First point coordinates / 第一点坐标
bnumber[]Second point coordinates / 第二点坐标

Returns

number

Distance / 距离

Example

ts
distance([0, 0], [3, 4]) // => 5

Since

1.0.0

Released under the MIT License.