Exemplo n.º 1
0
 static void Main()
 {
     Point3D firstPoint = new Point3D(10, 13, 15);
     Point3D secondPoint = new Point3D(12, 24, 34);
     double distance = CalculateDistance.CalculateDistanceBetweenPoints(firstPoint, secondPoint);
     Console.WriteLine(distance);
 }
Exemplo n.º 2
0
        public static List<Path> LoadPaths(string filePath)
        {
            StreamReader reader = new StreamReader(filePath);
            List<Path> paths = new List<Path>();
            using (reader)
            {
                string row = reader.ReadLine();
                while (row != null)
                {
                    if (row == "")
                    {
                        break;
                    }
                    List<Point3D> rows = new List<Point3D>();
                    string[] data = row.Split(new char[] { ')', '(' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < data.Length; i++)
                    {
                        double[] pointsSplit = data[i].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(double.Parse).ToArray();
                        Point3D point = new Point3D(pointsSplit[0], pointsSplit[1], pointsSplit[2]);
                        rows.Add(point);
                    }
                    Path currentPath = new Path(rows);
                    paths.Add(currentPath);
                    row = reader.ReadLine();
                }
            }

            return paths;
        }
Exemplo n.º 3
0
 public static double CalculateDistanceBetweenPoints(Point3D firstPoint, Point3D secondPoint)
 {
     double result = Math.Sqrt(Math.Pow(firstPoint.X - secondPoint.X, 2) + Math.Pow(firstPoint.Y - secondPoint.Y, 2) + Math.Pow(firstPoint.Z - secondPoint.Z, 2));
     return result;
 }
Exemplo n.º 4
0
 public Path(Point3D[] points)
 {
     this.points = points.ToList();
 }