Friday, August 6, 2010

C# - Graphics - Distance Between 2 Points


/*********************************************************************
Description: C# implementation for calculating distance between 2 points (x1,y1) and (x2,y2).
*********************************************************************/



public int DistanceBetween2Points(int x1, int y1, int x2, int y2)
{
    return (int)Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}


No comments:

Post a Comment