Skip to content

Instantly share code, notes, and snippets.

@lisardggY
Created March 23, 2016 08:52
Show Gist options
  • Save lisardggY/7003f5be9eb93153e28a to your computer and use it in GitHub Desktop.
Save lisardggY/7003f5be9eb93153e28a to your computer and use it in GitHub Desktop.
Calculate distance between two points
public static class PointExtensions
{
public static double DistanceFrom(this Point point1, Point point2)
{
// Pythagorean distance calculation.
return Math.Abs(
Math.Sqrt(
Math.Pow(point1.X - point2.X, 2) + Math.Pow(point1.Y - point2.Y, 2)
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment