c#计算两点距离

来源:互联网 发布:怎么用u盘重装mac系统 编辑:程序博客网 时间:2024/04/28 05:18

#region 计算两点距离
        /// <summary>
        /// 计算两点距离
        /// </summary>
        /// <param name="startPoint">起点</param>
        /// <param name="endPoint">终点</param>
        /// <returns></returns>
        public static double GetDistance(Point startPoint, Point endPoint)
        {
            int x = System.Math.Abs(endPoint.X - startPoint.X);
            int y = System.Math.Abs(endPoint.Y - startPoint.Y);
            return Math.Sqrt(x * x + y * y);
        }
        #endregion
0 0