コード例 #1
0
 public void GetPointStructFloatDistanceWOSqrt()
 {
     for (int i = 0; i < Arrays.pointsX.Length - 1; i++)
     {
         PointStruct point1   = new PointStruct(Arrays.pointsX[i], Arrays.pointsY[i]);
         PointStruct point2   = new PointStruct(Arrays.pointsX[i + 1], Arrays.pointsY[i + 1]);
         float       x        = point1.X - point2.X;
         float       y        = point1.Y - point2.Y;
         float       distance = (x * x) + (y * y);
     }
 }
コード例 #2
0
 public void GetPointStructDoubleDistance()
 {
     for (int i = 0; i < Arrays.pointsX.Length - 1; i++)
     {
         PointStruct point1   = new PointStruct(Arrays.pointsX[i], Arrays.pointsY[i]);
         PointStruct point2   = new PointStruct(Arrays.pointsX[i + 1], Arrays.pointsY[i + 1]);
         double      x        = point1.X - point2.X;
         double      y        = point1.Y - point2.Y;
         double      distance = Math.Sqrt((x * x) + (y * y));
     }
 }