mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
830 B
830 B
Function distance
Calculates the distance between two 2-dimensional points. The inputs are in the form of arrays.
Syntax
math.distance([x1, y1], [x2, y2]);
Parameters
| Parameter | Type | Description |
|---|---|---|
a |
Array | Matrix | Co-ordinates of first end-point |
b |
Array | Matrix | Co-ordinates of second end-point |
Returns
| Type | Description |
|---|---|
| Number | BigNumber | Returns the distance between two points |
Examples
math.distance([0, 0], [10, 10]) // Returns 14.142135623730951
math.distance(math.matrix([0,0]),math.matrix([10,10])) // Returns 14.142135623730951