static void Main() { Point3D point1 = new Point3D(0, 5, 8); Point3D point2 = new Point3D(1, 2, 4); Point3D point3 = new Point3D(-3, 15, 60); Point3D[] points = { point1, point2, point3 }; Path path = new Path(points); Point3D point4 = new Point3D(-10, 12, 80); Point3D point5 = new Point3D(11, 12, 5); Point3D point6 = new Point3D(-33, 155, 26); Point3D[] points1 = { point4, point5, point6 }; Path path1 = new Path(points1); Console.WriteLine(path.Distance); foreach (var point in path.Points) { Console.WriteLine(point); } string filePath = @"..\..\..\TxtFiles\4thTask.txt"; StreamWriter fileWrite = new StreamWriter(filePath, false, Encoding.GetEncoding(1251)); using (fileWrite) { PathStorage.SavePath(path, fileWrite); PathStorage.SavePath(path1, fileWrite); } StreamReader fileRead = new StreamReader(filePath, Encoding.GetEncoding(1251)); List <Path> readedPaths = PathStorage.LoadPaths(fileRead); foreach (var readedPath in readedPaths) { for (var i = 0; i < readedPath.Points.Length; i++) { Console.Write(readedPath.Points[i]); } Console.WriteLine(); } }
static void Main() { ////Create point Point3D point = new Point3D(1, 2, 3); Point3D secondPoint = new Point3D(2, 3, 4); //print point Console.WriteLine(point); Console.WriteLine(secondPoint); Console.WriteLine(Point3D.center); //calculte distance double distance = Distance.CalculteDistance(point, secondPoint); Console.WriteLine(distance); distance = Distance.CalculteDistance(point, Point3D.center); Console.WriteLine(distance); //Load paths List <Path> paths = PathStorage.LoadPaths(); //print loaded paths PrintPaths(paths); //Safe path to file Point3D firstPathPont = new Point3D(10, 11, 12); Point3D secondPathPoint = new Point3D(15, 16, 17); Point3D thirdPathPoint = new Point3D(20, 21, 22); Path path = new Path(firstPathPont, secondPathPoint, thirdPathPoint); PathStorage.SavePath(path); List <Path> pathsAfterLoading = PathStorage.LoadPaths(); //print paths PrintPaths(pathsAfterLoading); }
static void Main() { //set two 3D points Point3D firstPoint = new Point3D(1, 2, 3); Point3D secondPoint = new Point3D(4, 5, 6); //make instanse of Path Object and add three points to it. Path pointSequence = new Path(); pointSequence.AddToPath(firstPoint); pointSequence.AddToPath(secondPoint); //using static property O which retursn (0,0,0) pointSequence.AddToPath(firstPoint.O); //Get the path of points by GetPath method which returns List<Point3D> and print the path var path = new List <Point3D>(); path = pointSequence.GetPath(); foreach (var point in path) { Console.WriteLine(point); } //Add new line in the PointCollection.txt file string filePath = @"..\..\PointCollection.txt"; PathStorage.SaveToPath(filePath, firstPoint); //Calculate the distanse between two 3D points Console.WriteLine("Distance = " + VectorMagnitude3D.MagnitudeByPoints(firstPoint, secondPoint)); //Load and display the content of the file PointCollection.txt var fileContent = PathStorage.LoadPath(filePath); foreach (var line in fileContent) { Console.WriteLine(line); } }