static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");//culture US is used becouse we need to load points from file wich coordinate values are // represented by float point '.', otherwise a conflict will apear when we try to // convert it to 'Double'. List<Point3D> points = new List<Point3D>(); Path storedPoints = new Path();//call empty consturctor and all points in 'Path' are saved to 'List<>' in it. points.AddRange(storedPoints.RetrunPoints()); // store all points from 'Path' class to our Main(Core) Console.WriteLine(); Console.WriteLine(" y "); Console.WriteLine(); Console.WriteLine(" ^ "); Console.WriteLine(" P__. 1 "); Console.WriteLine(" /| . Euclidean Three Dimension Space "); Console.WriteLine(" / |.7._____ Q Each Point is represented by [X,Y,Z}"); Console.WriteLine(" / | . /| values on the coordinate system "); Console.WriteLine(" / | . / | "); Console.WriteLine(" / | . / | "); Console.WriteLine(" / | . / | "); Console.WriteLine(" / | ./ | "); Console.WriteLine("-z <. . . . | /. . .| . . . . . . > z "); Console.WriteLine(" -1 | /. .5 "); Console.WriteLine(" ./ "); Console.WriteLine(" . 1 "); Console.WriteLine(" . "); Console.WriteLine(" . "); Console.WriteLine(" |_ "); Console.WriteLine(); Console.WriteLine(" x "); Console.WriteLine(); Console.WriteLine("P " + points[0]); Console.WriteLine("Q " + points[1]); Console.WriteLine("Dsitance between P and Q = " + EuclideanDistance.CalcDistanceBetweenTwoPoints(points[0], points[1]) + " [Units]"); points.AddRange(PathStorage.Load()); //call method to load points from a file Console.WriteLine(); Console.WriteLine("Points from File:"); Console.WriteLine(); Console.WriteLine("K " + points[2]); Console.WriteLine("L " + points[3]); Console.WriteLine(); PathStorage.Save(points); //invoke a method to save points in 'output.txt' Console.WriteLine("Points saved to output.txt."); Console.WriteLine(); Console.WriteLine("Zero Point: {0}",Point3D.PointZero); }
static void Main() { const string fileName = "PathSaved.txt"; Console.ForegroundColor = ConsoleColor.Cyan; //create instance of class point and test the override ToString method Point firstPoint = new Point(1.0, 2.0, 3.0); Console.WriteLine(firstPoint.ToString()); //test if the default constructor works correctly Point secondPoint = Point.PointO; Console.WriteLine(secondPoint); // Math.Sqrt( (0 - 1) ^ 2 + ( 0 - 2 ) ^ 2 + ( 0 - 3 ) ^ 2 ) = Math.Sqrt(14) double distance = Distance.CalculateDistance(firstPoint, secondPoint); Console.ResetColor(); //check if calculate distance works correctly Console.WriteLine(distance); Console.WriteLine(Math.Sqrt(14)); //test Path class Path path = new Path(); path.AddPoint(new Point(1.5, 1.19, 29d)); path.AddPoint(new Point(7.4, 19.1, 17.14)); path.AddPoint(firstPoint); //test the static method SavePath //using constant file name for easier testing PathStorage.SavePath(path, fileName); Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine(); //print path after deleting the first point path.RemoveFirstPoint(); path.Print(); //test the static method LoadPath //using constant file name for easier testing Path pathBeforeRemovingPoint = PathStorage.LoadPath(fileName); Console.ResetColor(); pathBeforeRemovingPoint.Print(); }