UNPKG
chebyshev
Version:
latest (0.2.1)
0.2.1
0.2.0
0.1.0
Determine the Chebyshev distance between two points
github.com/semibran/chebyshev
semibran/chebyshev
chebyshev
/
index.js
12 lines
(11 loc)
•
294 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
module
.
exports
=
function
chebyshev
(
a, b
) {
var
farthest =
0
var
dimensions =
Math
.
max
(a.
length
, b.
length
)
for
(
var
i =
0
; i < dimensions; i++) {
var
distance =
Math
.
abs
((b[i] ||
0
) - (a[i] ||
0
))
if
(distance > farthest) { farthest = distance } }
return
farthest }