static void Main(string[] args) { Point3D p1 = new Point3D() { X = 3, Y = 5, Z = 3 }; Point3D p2 = new Point3D() { X = 3, Y = 5, Z = 5 }; Console.WriteLine("This is a 3D Point : " +p1); Console.WriteLine("This is another 3D Point : " + p2); Console.WriteLine("The distance between these two points is :" +Point3D.Distance(p1, p2)); Console.WriteLine(); Console.WriteLine("Zero Point is : " + Point3D.ZeroPoint); Console.WriteLine(); Path p = new Path(new List<Point3D>()); // loading path from external file Console.WriteLine("Loading points from external file."); PathStorage.LoadPath(@"../../input.txt", p); Console.WriteLine(); Console.WriteLine("Printing Points from the external file."); foreach (var point in p.CurrentPath) { Console.WriteLine(point); } Console.WriteLine(p.CurrentPath[0]); // saving the path to external file PathStorage.SavePath(@"../../input.txt", p); }
//Write a static class with a static method to calculate //the distance between two points in the 3D space. public static double Distance(Point3D p1, Point3D p2) { return Math.Sqrt((p2.X - p1.X) * (p2.X - p1.X) + (p2.Y - p1.Y) * (p2.Y - p1.Y) + (p2.Z - p1.Z) * (p2.Z - p1.Z)); }