public static Path Load() { Path loaded = new Path(); StreamReader reader = new StreamReader("file.txt"); using (reader) { string line = reader.ReadLine(); while (line != null) { string[] currentLine; Point3d currentPoint = new Point3d(); currentLine = ExtractPaths(line); if (currentLine.Length == 3) { currentPoint.X = int.Parse(currentLine[0]); currentPoint.Y = int.Parse(currentLine[1]); currentPoint.Z = int.Parse(currentLine[2]); } else { throw new IndexOutOfRangeException("You could use exactly three points"); } loaded.Add(currentPoint); line = reader.ReadLine(); } } return loaded; }
public static double Distance(Point3d p1, Point3d p2) { double x = Math.Pow(p1.X - p2.X, 2); double y = Math.Pow(p1.Y - p2.Y, 2); double z = Math.Pow(p1.Z - p2.Z, 2); double distance = Math.Sqrt(x + y + z); return distance; }
private static void Main() { Point3d firstPoint = new Point3d(1, 2, 3); Point3d secondPoint = new Point3d(4, 5, 6); Console.WriteLine("First point " + firstPoint); Console.WriteLine("Second point " + secondPoint); Console.WriteLine("Start point " + Point3d.StartPoint); Console.WriteLine("Distance between first and second point " + Calculate3d.Distance(firstPoint, secondPoint)); Path paths = new Path(); paths.Add(firstPoint); paths.Add(secondPoint); Console.WriteLine("All points: "); Console.Write(paths); PathStorage.Save(paths); Console.WriteLine("Loaded: "); Path loadedPaths = PathStorage.Load(); Console.Write(loadedPaths); }
public void Delete(Point3d point) { this.Points.Add(point); }
public void Add(Point3d point) { this.Points.Add(point); }