Skip to content

Instantly share code, notes, and snippets.

@msalahat
Created March 24, 2017 22:18
Show Gist options
  • Save msalahat/8a4f424326446926b49b24000970d193 to your computer and use it in GitHub Desktop.
Save msalahat/8a4f424326446926b49b24000970d193 to your computer and use it in GitHub Desktop.
Calculate Distance Between 2 pixels in 2D sphere
const calculate_distance = (x1, y1, x2, y2) => {
let xd = x2 - x1;
let yd = y2 - y1;
let distance = Math.sqrt(xd * xd + yd * yd);
return distance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment