Calculate the Euclidean distance been two points in 2D/3D/nD space.
JavaScript
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test add squared method, standardize, clean up readme Dec 28, 2015
.gitignore it is alive in n dimensions Oct 22, 2013
.travis.yml add .travis.yml Jan 9, 2014
LICENSE.md
README.md add squared method, standardize, clean up readme Dec 28, 2015
index.js add squared method, standardize, clean up readme Dec 28, 2015
package.json cleanup Dec 28, 2015
squared.js add squared method, standardize, clean up readme Dec 28, 2015

README.md

Euclidean Distance Build Status

euclidean-distance is a browserify-friendly npm module for calculating the Euclidean distance

between two vectors in n-dimensional space.

Installation

npm install euclidean-distance --save

Usage

var distance = require('euclidean-distance')

distance([0,0], [1,0])
// 1

distance([0,0], [3,2])
// 3.605551275463989

distance([-7,-4,3], [17, 6, 2.5])
// 26.004807247892

distance([5,13,17,3,25,21,7,1], [20,26,7,5,28,3,23,10])
// 34.17601498127012

For some purposes you may actually be looking for the square of the distance. For that, you can use:

var distanceSquared = require('euclidean-distance/squared')

distanceSquared([0,0], [2,0])
// 4

Test

npm test

License

WTFPL