Calculate the distance between two points.
Distance Formula
private static double GetDistance(PointF point1, PointF point2)
{
//pythagoras theorem c^2 = a^2 + b^2
//thus c = square root(a^2 + b^2)
double a = (double)(point2.X - point1.X);
double b = (double)(point2.Y - point1.Y);
return Math.Sqrt(a * a + b * b);
}
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.