Distance Formula

vckicks 0 Tallied Votes 312 Views Share

Calculate the distance between two points.

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);
}