mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
758 B
758 B
Function distance
Calculates the Euclidean distance between two points.
Syntax
math.distance([x1, y1], [x2, y2]);
math.distance([[x1, y1], [x2, y2]);
Parameters
| Parameter | Type | Description |
|---|---|---|
x |
Array | Matrix | Co-ordinates of first end-point of first line |
y |
Array | Matrix | Co-ordinates of second end-point of first line |
Returns
| Type | Description |
|---|---|
| Number | BigNumber | Returns the distance from two points |
Examples
math.distance([0,0], [4,4]) //returns 5.6569
math.distance([[0,0], [4,4]]) //returns 5.6569