Skip to content

Instantly share code, notes, and snippets.

@pjdietz
Created May 8, 2013 13:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjdietz/5540472 to your computer and use it in GitHub Desktop.
Save pjdietz/5540472 to your computer and use it in GitHub Desktop.
Calculate distance between two points.
/** Return the distance between two points */
public static double distance(float x1, float y1, float x2, float 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