static void Main() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Path points = PathStorage.LoadPath("..\\..\\TestFiles\\Input.txt"); foreach (Point3D point in points) { Console.WriteLine(point); } Console.WriteLine(Point3D.Origin); double shortestDistance = Double.MaxValue; for (int i = 0; i < points.Count - 1; i++) { for (int j = i + 1; j < points.Count; j++) { double distance = DistanceFinder.CalcDistance(points[i], points[j]); if (shortestDistance > distance) { shortestDistance = distance; } } } Console.WriteLine("The distance between the closest points is {0:F2}.", shortestDistance); }
public void TestCalcDistance() { Path points = new Path(); Point3D point1 = new Point3D(0, 0, 0); points.Add(point1); Point3D point2 = new Point3D(1, 1, 0); points.Add(point2); double distance = DistanceFinder.CalcDistance(points[1], points[0]); Assert.AreEqual(1.41, Math.Round(distance, 2)); }