Ejemplo n.º 1
0
        /// <summary>
        /// 计算最邻近平均距离
        /// </summary>
        /// <param name="index">最邻近距离的基准点</param>
        /// <param name="points">统计点集</param>
        /// <returns>返回以第index个点作为基准点的最邻近平均距离</returns>
        public static double wxzNNADistance(params FeatureClass.Point[] points)
        {
            int    len = points.Length;
            double sum = 0;

            for (int i = 0; i < len; i++)
            {
                FeatureClass.Point targetPt    = points[i];
                double             minDistance = 999999999;
                for (int j = 0; j < len; j++)
                {
                    if (i != j)
                    {
                        double distance = wxzDistance(targetPt, points[j]);
                        if (distance < minDistance)
                        {
                            minDistance = distance;
                        }
                    }
                }
                sum += minDistance;
            }
            return(sum / len);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 计算平面上两点间的最短距离
 /// </summary>
 /// <param name="p1">第一个点</param>
 /// <param name="p2">第二个点</param>
 /// <returns>返回两点间的距离</returns>
 public static double wxzDistance(FeatureClass.Point p1, FeatureClass.Point p2)
 {
     return(Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2)));
 }