Created
March 23, 2016 08:52
-
-
Save lisardggY/7003f5be9eb93153e28a to your computer and use it in GitHub Desktop.
Calculate distance between two points
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
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