Skip to content

Instantly share code, notes, and snippets.

@ashblue
Created October 5, 2012 19:36
Show Gist options
  • Save ashblue/3841880 to your computer and use it in GitHub Desktop.
Save ashblue/3841880 to your computer and use it in GitHub Desktop.
Distance between points using two vertices
/**
* Calculates the distqance between two vertices and returns the value
* @param {array} startVert Start x and y point
* @param {array} endVert End x and y point
* @returns {number}
*/
function distanceBetweenPoints (startVert, endVert) {
return Math.sqrt(Math.pow(endVert[0] - startVert[0], 2) + Math.pow(endVert[1] - startVert[1], 2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment