public static Tuple <ThreePoints[], ThreePoints[], double> TripleEuclidean(ThreePoints[] threeVectors) { ThreePoints[] threePointA = new ThreePoints[1]; ThreePoints[] threePointB = new ThreePoints[1]; double curDistance = int.MaxValue; foreach (var item in threeVectors) { for (int i = 0; i < threeVectors.Length - 1; i++) { int exs = threeVectors[i + 1].x - threeVectors[i].x; int ys = threeVectors[i + 1].y - threeVectors[i].y; int zs = threeVectors[i + 1].z - threeVectors[i].z; double distance = Math.Sqrt((exs * exs) + (ys * ys) + (zs * zs)); if (distance <= curDistance) { threePointA[0].x = threeVectors[i].x; threePointA[0].y = threeVectors[i].y; threePointA[0].z = threeVectors[i].z; threePointB[0].x = threeVectors[i + 1].x; threePointB[0].y = threeVectors[i + 1].y; threePointB[0].z = threeVectors[i + 1].z; curDistance = distance; } } } return(Tuple.Create(threePointA, threePointB, curDistance)); }
// public static Tuple<double, double> TwoClosest(double[] input) // { // Array.Sort(input); // // return Tuple.Create(input[0], input[1]); // } public static ThreePoints[] ThreePointArray(Random point) { ThreePoints[] threeVectors = new ThreePoints[1000]; for (int i = 0; i < threeVectors.Length; i++) { threeVectors[i] = new ThreePoints(point); } return(threeVectors); }