//method for loading already saved path
        public static Path Load()
        {
            //we need to create new path, because the method returns a Path
            Path tempPoints = new Path();
            StreamReader reader = new StreamReader(@"../../PathSaves.txt");

            //loading the path
            using (reader)
            {
                //read a line and separates all its elements into an array
                string line = reader.ReadLine();

                string[] numbers = line.Trim().Split();

               //this int will be used when trying to parse an element from the array
                int temp;

                //the counter will help us to know, if we have to write x,y or z, when find a digits from the elements
                int counter = 0;

                //3d point that will store current x,y,z before being written in the path
                Point3D tempPoint = new Point3D();

                foreach (string s in numbers)
                {
                    //counter>2 means that tempPoint has all x,y,z coordinates found
                    //tempPoint and counter must be reseted and start again with a new 3d point with its x coordinate
                      if(counter>2)
                        {
                            counter = 0;
                            tempPoints.Add(tempPoint);
                            tempPoint = new Point3D();
                        }

                    //check if s is int or not
                    //if it's digit write it as x,y or z depending on counter
                    //if not just continue with the next element s
                    if (Int32.TryParse(s, out temp))
                    {
                        if (counter == 0)
                        {
                            tempPoint.X = temp;
                            counter++;
                        }
                        else if (counter == 1)
                        {
                            tempPoint.Y = temp;
                            counter++;
                        }
                        else if (counter == 2)
                        {
                            tempPoint.Z = temp;
                            counter++;
                        }

                    }
                }

                //when foreach loop finishes with all elements in the array we must check,
                //if there's a 3d point, which is not written to the path
                if (counter > 2)
                {
                    counter = 0;
                    tempPoints.Add(tempPoint);
                    tempPoint = new Point3D();
                }

            }
            return tempPoints;
        }
 //add points to the path
 public void Add(Point3D point)
 {
     this.path.Add(point);
 }
 //just one method in this class for distance calculation between two 3d points. Euclidean distance algorithm is use
 public static double Distance(Point3D point1, Point3D point2)
 {
     double result = (double)Math.Sqrt(((point1.X - point2.X) * (point1.X - point2.X) + (point1.Y - point2.Y) * (point1.Y - point2.Y) + (point1.Z - point2.Z) * (point1.Z - point2.Z)));
     return result;
 }