get distance between two points
Published: 13. December 2008 | Updated: 5. November 2011License: Microsoft Public License (MS-PL)
Categories: GDI, Framework » Math
Tags: C# GDI Math Winforms WPF
Short code snippet for obtain distance from one Point to another
Import namespaces
// in winforms using System.Drawing; // in wpf using System.Windows;
Code
public static double GetDistanceBetweenPoints(Point p, Point q) { double a = p.X - q.X; double b = p.Y - q.Y; double distance = Math.Sqrt(a * a + b * b); return distance; }
| Send us feedback about this snippet » |





