Created
July 14, 2013 01:32
-
-
Save jremmen/5992854 to your computer and use it in GitHub Desktop.
calculate distance between two points
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Point = function(x, y) { | |
this.x = x; | |
this.y = y; | |
}; | |
function getDistance(a, b) { | |
return Math.sqrt(Math.pow((a.x - b.x), 2) + Math.pow((a.y - b.y), 2)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot