public static double CalcDistance(ThreeDPoint firstPoint, ThreeDPoint secondPoint) { double firstEquation = (secondPoint.X - firstPoint.X) * (secondPoint.X - firstPoint.X); double secondEquation = (secondPoint.Y - firstPoint.Y) * (secondPoint.Y - firstPoint.Y); double thirdEquation = (secondPoint.Z - firstPoint.Z) * (secondPoint.Z - firstPoint.Z); double distance = Math.Sqrt(firstEquation + secondEquation + thirdEquation); return distance; }
static void Main() { ThreeDPoint firstPoint = new ThreeDPoint(1.3, 3.0, 2.7); ThreeDPoint secondPoint = new ThreeDPoint(3.2, 2.5, 1.0); Console.WriteLine("First point coordinates: {0}", firstPoint); Console.WriteLine("Second point coordinates: {0}", secondPoint); Console.WriteLine("Distance between first and second point: {0:F2}", CalculateDistance.CalcDistance(firstPoint, secondPoint)); Path listOfPaths = new Path(); listOfPaths.AddPoint(firstPoint); listOfPaths.AddPoint(secondPoint); PathStorage.SavePathToFile(@"../../PathStorageTest.txt",listOfPaths); PathStorage.LoadPathFromFile(@"../../PathStorageTest.txt"); Console.WriteLine("List of paths stored in text file:"); foreach (ThreeDPoint point in listOfPaths.Points) { Console.WriteLine(point); } }
static ThreeDPoint() { pointZero = new ThreeDPoint(0, 0, 0); }
public void AddPoint(ThreeDPoint point) { points.Add(point); }