Created
December 19, 2014 16:13
-
-
Save JonCatmull/3d7169797fb9581f0302 to your computer and use it in GitHub Desktop.
Get distance between to points in JavaScript
This file contains 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
function distance(x1,y1,x2,y2) { | |
return Math.sqrt(Math.pow((x1-x2),2)+Math.pow((y1,y2),2)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Math.pow((y1, y2), 2)
You meant to put a minus there, not comma