//load file
        public static Path LoadFile()
        {
            Path currentPath = new Path();

            using (readFile)
            {
                string line = readFile.ReadLine();

                while (line != null)
                {
                    string[] numbers = line.Split(' ');

                    Point3DCoordinates currentPoint = new Point3DCoordinates()
                    {
                        X = decimal.Parse(numbers[0]),
                        Y = decimal.Parse(numbers[1]),
                        Z = decimal.Parse(numbers[2])
                    };

                    currentPath.AddPoint(currentPoint);

                    line = readFile.ReadLine();
                }
            }

            return(currentPath);
        }
Пример #2
0
        //calculating distance between points

        public static decimal DistanceBetweenPoints(Point3DCoordinates first, Point3DCoordinates second)
        {
            decimal xd = first.X - second.X;
            decimal yd = first.Y - second.Y;
            decimal zd = first.Z - second.Z;

            return((decimal)Math.Sqrt((double)(xd * xd + yd * yd + zd * zd)));
        }
Пример #3
0
        static void Main()
        {
            //just for testing the classes and structures

            Path newPath             = PathStorage.LoadFile();
            Point3DCoordinates point = new Point3DCoordinates(1, 2, 6);

            newPath.AddPoint(point);

            foreach (var item in newPath.path)
            {
                Console.WriteLine(item.ToString());
            }

            PathStorage.SaveFile(newPath);

            Point3DCoordinates first  = new Point3DCoordinates(1, 2, 3);
            Point3DCoordinates second = new Point3DCoordinates(1, 5, 8);

            Console.WriteLine(Distance.DistanceBetweenPoints(first, second));
        }
Пример #4
0
 //add point to path
 public void AddPoint(Point3DCoordinates point)
 {
     path.Add(point);
 }
Пример #5
0
 //remove point from path
 public void RemovePoint(Point3DCoordinates point)
 {
     path.Remove(point);
 }