Ejemplo n.º 1
0
        public static Path LoadPath(string pathToFile)
        {
            if (pathToFile == string.Empty || !File.Exists(pathToFile))
            {
                throw new ArgumentException("The path is wrong or file doesn't exist!");
            }

            StreamReader read = new StreamReader(pathToFile);
            Path pointsSpace = new Path();

            string line;
            using (read)
            {
                line = read.ReadLine();
                while (line != null)
                {
                    string[] coordinates = line.Split(new char[] { ' ', ','}, StringSplitOptions.RemoveEmptyEntries);

                    Structure3DPoint point =
                        new Structure3DPoint(int.Parse(coordinates[0]), int.Parse(coordinates[1]), int.Parse(coordinates[2]));
                    pointsSpace.AddPoint(point);

                    line = read.ReadLine();
                }
            }
            return pointsSpace;
        }
Ejemplo n.º 2
0
        public static double FindDistance(Structure3DPoint pointA, Structure3DPoint pointB)
        {
            int deltaX = pointB.XCoord - pointA.XCoord;
            int deltaY = pointB.YCoord - pointA.YCoord;
            int deltaZ = pointB.ZCoord - pointA.ZCoord;

            return Math.Sqrt((deltaX * deltaX) + (deltaY * deltaY) + (deltaZ * deltaZ));
        }
Ejemplo n.º 3
0
        static void Main()
        {
            Structure3DPoint pointA = new Structure3DPoint();
            Structure3DPoint pointB = new Structure3DPoint(1,1,1);
            double distance = 0;
            Console.WriteLine(pointB);
            Console.WriteLine(Structure3DPoint.Point0);

            distance = Distance.FindDistance(pointA, pointB);
            Console.WriteLine(distance);

            Path space = new Path(pointA, pointB);

            PathStorage.SavePath("../../SavePath.txt", space);

            Path loadPath = new Path();

            loadPath = PathStorage.LoadPath("../../LoadPath.txt");
            PathStorage.SavePath("../../NewPath", loadPath);
        }
Ejemplo n.º 4
0
 // METHODS --------------------------------------------------------------
 public void AddPoint(Structure3DPoint point)
 {
     this.path3D.Add(point);
 }