public static double Calc3DPointDistance(Point3D pointA, Point3D pointB) { return Math.Sqrt( Math.Pow(pointB.Xaxis - pointA.Xaxis, Pow) + Math.Pow(pointB.Yaxis - pointA.Yaxis, Pow) + Math.Pow(pointB.Zaxis - pointA.Zaxis, Pow)); }
public static Path3D LoadPath(string fileName) { List<Point3D> points = new List<Point3D>(); Path3D path; try { StreamReader sr = new StreamReader(fileName); using (sr) { String line = sr.ReadLine(); while (line != null) { double[] coordinates = PointExtractor(line); Point3D p = new Point3D(coordinates[0], coordinates[1], coordinates[2]); points.Add(p); line = sr.ReadLine(); } } } catch (Exception e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } path = new Path3D(points); return path; }
static void Main(string[] args) { Point3D p1 = new Point3D(2, 3, 8); Console.WriteLine("Problem 1. Point3D"); Console.WriteLine(p1); Console.WriteLine(Point3D.StartingPoint); Console.WriteLine(); Console.WriteLine("Problem 2. Distance Calculator"); Point3D p = new Point3D(-7, -4, 3); Console.WriteLine(p); Point3D q = new Point3D(17, 6, 2.5); Console.WriteLine(q); Console.WriteLine(); Console.WriteLine(DistanceCalculator.CalculateDistance(p, q)); Console.WriteLine(); Console.WriteLine("Write to File: "); _03_Paths path = new _03_Paths(p, q, Point3D.StartingPoint); Console.WriteLine(path); path.WriteToFile("../../points.txt"); Console.WriteLine("Read From File: "); _03_Paths pathFromFile = _03_Paths.ReadFromFile("../../points.txt"); Console.WriteLine(pathFromFile); }
static void Main() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Point3D start = Point3D.StartingPoint; Console.WriteLine(start); Point3D p = new Point3D(2.3, 4.8, 16.9); Console.WriteLine(p); Point3D q = new Point3D(2.8, 16, -5); Console.WriteLine(p); double distance = DistanceCalculator.CalcDistance(q, p); Console.WriteLine("The distance between the points is: " + distance); Path3D myPath = new Path3D(p, q, start); Console.WriteLine("My path is: "); Console.WriteLine(myPath); Console.WriteLine("My path's total lenght is: " + myPath.TotalDistance); Storage.WritePathToTxt(myPath); Path3D readedPath = Storage.ReadPathFromTxt("../../txtFiles/input.txt"); Console.WriteLine("This path war read from the text file: "); Console.WriteLine(readedPath); Console.WriteLine("Readed path's total lenght is: " + readedPath.TotalDistance); }
static void Main(string[] args) { Point3D p1 = new Point3D(2.5, 5, 99.9); Point3D zeroPoint = Point3D.StartingPoint; Console.WriteLine(p1); Console.WriteLine(zeroPoint); }
static void Main(string[] args) { Console.WriteLine(Point3D.StartPointCordinates); Point3D fistPoint = new Point3D(3,5,2); Point3D secondPoint = new Point3D(4,8.4,11); double distance = DistanceCalculator.Calc3DPointDistance(fistPoint, secondPoint); Console.WriteLine("Distance = "+distance); }
static void Main() { Point3D p1 = new Point3D(1, 2, 3); Point3D p2 = new Point3D(2, 3, 4); Point3D p3 = new Point3D(3, 4, 5); Paths3D myPath = new Paths3D(); myPath.AddPoint(p1); myPath.AddPoint(p2); myPath.AddPoint(p3); }
public static double CalcDistance(Point3D firstPoint, Point3D secondPoint) { return Math.Sqrt ( (secondPoint.X - firstPoint.X) * (secondPoint.X - firstPoint.X) + (secondPoint.Y - firstPoint.Y) * (secondPoint.Y - firstPoint.Y) + (secondPoint.Z - firstPoint.Z) * (secondPoint.Z - firstPoint.Z) ); }
static void Main(string[] args) { var point = new Point3D(1.6, 6.9, 8); Console.WriteLine(point); }