static void Main(string[] args) { Point3D first = new Point3D(-7, -4, 3); Console.WriteLine(first); Point3D statics = new Point3D(17, 6, 2.5); Console.WriteLine("{0:0.000}", DistanceCalculator.DistanceBetween(first, statics)); Console.WriteLine(first); Path a = new Path(); a.AddPoint(first); a.AddPoint(statics); Console.WriteLine(a); Storage.Save(a); Path newPath = Storage.Load(a); Console.WriteLine(newPath); }
internal static Path Load(Path a) { string input = File.ReadAllText("PathOut.txt").Trim('[', ']'); string[] values = new string[3]; values = input.Split(new char[] { ',', ' ', '\r', '\n', '[', ']' }, StringSplitOptions.RemoveEmptyEntries); Path inputAsPath = new Path(); Regex splits = new Regex(", "); for (int i = 0; i < values.Length; i += 3) { Point3D temp = new Point3D(double.Parse(values[i]), double.Parse(values[i + 1]), double.Parse(values[i + 2])); inputAsPath.AddPoint(temp); } Console.WriteLine("LOADED"); return inputAsPath; }
public static double DistanceBetween(Point3D a, Point3D b) { return Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y) + (a.Z - b.Z) * (a.Z - b.Z)); }
public void AddPoint(Point3D a) { this.sequence.Add(a); }