public static Path LoadFile() { Path pathInUse = new Path(); using (loadFile) { string row = loadFile.ReadLine(); while (row != null) { string[] coords = row.Split(); Point3DCoord currentPoint = new Point3DCoord() { X = double.Parse(coords[0]), Y = double.Parse(coords[1]), Z = double.Parse(coords[2]), }; pathInUse.InsertPoint(currentPoint); row = loadFile.ReadLine(); } } return(pathInUse); }
public static double DistanceCalculation(Point3DCoord firstPoint, Point3DCoord secondPoint) { double distX = Math.Pow((firstPoint.X - secondPoint.X), 2); double distY = Math.Pow((firstPoint.Y - secondPoint.Y), 2); double distZ = Math.Pow((firstPoint.Z - secondPoint.Z), 2); double totalDist = Math.Sqrt(distX + distY + distZ); return(totalDist); }
static void Main() { Path newPath = PathStorage.LoadFile(); Point3DCoord point = new Point3DCoord(5, 10, 15); newPath.InsertPoint(point); foreach (var item in newPath.pathToSequence) { Console.WriteLine(item.ToString()); } PathStorage.SaveFile(newPath); Point3DCoord firstPoint = new Point3DCoord(1, 1, 2); Point3DCoord secondPoint = new Point3DCoord(2, 1, 1); Console.WriteLine(CalculateDistance.DistanceCalculation(firstPoint, secondPoint)); }
public void RemovePoint(Point3DCoord pointToRemove) { pathToSequence.Remove(pointToRemove); }
public void InsertPoint(Point3DCoord newPoint) { pathToSequence.Add(newPoint); }