static void Main(string[] args) { Console.WriteLine("Starting point:"); Console.WriteLine(Point3D.StartPoint.ToString()); Console.WriteLine(); Point3D a = new Point3D("A", 1, 2, 1.5); Point3D b = new Point3D("B", -1, 2, 1.5); Point3D c = new Point3D("C", 1, -2, 1.5); Point3D d = new Point3D("D", 1, 2, -1.5); Path3D path = new Path3D(a, b, c, d); Console.WriteLine("The points of the path:"); Console.WriteLine(path.ToString()); Console.WriteLine(); Console.WriteLine("The distance between point A and point C:"); Console.WriteLine(DistanceCalculator.CalculateDistance3D(a,c)); Console.WriteLine(); Storage.MakePath("../../user_files/Paths.txt", false, path); Storage.MakePath("../../user_files.Paths.txt", true, path); var loaded = Storage.LoadPath(@"../../user_files/Paths.txt"); loaded.ForEach(p => Console.WriteLine(p.ToString())); }
public static double CalculateDistance3D(Point3D firstPoint, Point3D secondPoint) { double distance = 0; distance = Math.Sqrt(Math.Pow((firstPoint.X - secondPoint.X), 2) + Math.Pow((firstPoint.Y - secondPoint.Y), 2) + Math.Pow((firstPoint.Z - secondPoint.Z), 2)); return distance; }
public static Point3D Regular(string point) { Regex regx = new Regex(@"(.+?){(.+?),(.+?),(.+?)}"); MatchCollection matches = regx.Matches(point); var group = (matches[0] as Match).Groups; Point3D result = new Point3D(group[1].Value, double.Parse(group[2].Value), double.Parse(group[3].Value), double.Parse( group[4].Value)); return result; }
public static void MakePath(string fileName, bool append, Point3D path) { try { using(StreamWriter writer = new StreamWriter(fileName, append, Encoding.GetEncoding("UTF-8"))) { writer.WriteLine(path.ToString()); } } catch(Exception ex) { Console.WriteLine(ex.Message); throw ex.InnerException; } }
public void Add(Point3D point) { this.Paths.Add(point); }
static Point3D() { startPoint = new Point3D("start", 0, 0, 0); }