Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            StructPoint3D point = new StructPoint3D();

            {
                point.X = 4.3;
                point.Y = 6.2;
                point.Z = 2.1;
            }

            Console.WriteLine(point.ToString());
            double dist = Distance.CalculateDistance(point, StructPoint3D.ZeroPoint);

            Console.WriteLine(dist);

            List <StructPoint3D> p = PathStorage.LoadPath();

            foreach (var item in p)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();
            p.Add(point);
            PathStorage.SavePath(p);

            foreach (var item in p)
            {
                Console.WriteLine(item);
            }
        }
Ejemplo n.º 2
0
 public static double CalculateDistance(StructPoint3D firstPoint, StructPoint3D secondPoint)
 {
     double distance = Math.Sqrt((firstPoint.X - secondPoint.X) * (firstPoint.X - secondPoint.X)
                                 + (firstPoint.Y - secondPoint.Y) * (firstPoint.Y - secondPoint.Y)
                                 + (firstPoint.Z - secondPoint.Z) * (firstPoint.Z - secondPoint.Z));
     return distance;
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            StructPoint3D point = new StructPoint3D();
            {
                point.X = 4.3;
                point.Y = 6.2;
                point.Z = 2.1;
            }

            Console.WriteLine(point.ToString());
            double dist = Distance.CalculateDistance(point,StructPoint3D.ZeroPoint);
            Console.WriteLine(dist);

            List<StructPoint3D> p = PathStorage.LoadPath();
            foreach (var item in p)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();
            p.Add(point);
            PathStorage.SavePath(p);

            foreach (var item in p)
            {
                Console.WriteLine(item);
            }
        }
Ejemplo n.º 4
0
        public static double CalculateDistance(StructPoint3D firstPoint, StructPoint3D secondPoint)
        {
            double distance = Math.Sqrt((firstPoint.X - secondPoint.X) * (firstPoint.X - secondPoint.X)
                                        + (firstPoint.Y - secondPoint.Y) * (firstPoint.Y - secondPoint.Y)
                                        + (firstPoint.Z - secondPoint.Z) * (firstPoint.Z - secondPoint.Z));

            return(distance);
        }
Ejemplo n.º 5
0
        static void Main()
        {
            var firstPoint  = new StructPoint3D(32, 40, 0);
            var secondPoint = new StructPoint3D(154, 284, -255);

            // Print start point coordinates
            Console.WriteLine(StructPoint3D.StartPoint3D.ToString());

            // Print First 3D Point's coordinates
            Console.WriteLine(firstPoint.ToString());

            // Second 3D Point's coordinates
            Console.WriteLine(secondPoint.ToString());

            Console.Write(Environment.NewLine);
            Console.Write("Distance between points: ");
            Console.WriteLine(CalculateTheDistance.CalcDistance(firstPoint, secondPoint));
        }
Ejemplo n.º 6
0
        public static List <StructPoint3D> LoadPath()
        {
            List <StructPoint3D> loadPath = new List <StructPoint3D>();

            try
            {
                StreamReader reader = new StreamReader(@"../../PathFile.txt");

                using (reader)
                {
                    string line = reader.ReadLine();
                    while (line != null)
                    {
                        StructPoint3D point  = new StructPoint3D();
                        string[]      points = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        point.X = double.Parse(points[0]);
                        point.Y = double.Parse(points[1]);
                        point.Z = double.Parse(points[2]);
                        loadPath.Add(point);
                        line = reader.ReadLine();
                    }
                }
            }

            catch (DirectoryNotFoundException)
            {
                Console.WriteLine("The file path contains a directory that cannot be found!");
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("The file was not found!");
            }
            catch (ArgumentNullException)
            {
                Console.WriteLine("No file path is given!");
            }
            catch (ArgumentException)
            {
                Console.WriteLine("The entered file path is not correct!");
            }
            catch (PathTooLongException)
            {
                Console.WriteLine("The entered file path is too long - 248 characters are the maximum!");
            }
            catch (UnauthorizedAccessException uoae)
            {
                Console.WriteLine(uoae.Message);
            }
            catch (SecurityException)
            {
                Console.WriteLine("You don't have the required permission to access this file!");
            }
            catch (NotSupportedException)
            {
                Console.WriteLine("Invalid file path format!");
            }
            catch (IOException ioe)
            {
                Console.WriteLine(ioe.Message);
            }
            return(loadPath);
        }
Ejemplo n.º 7
0
        public static List<StructPoint3D> LoadPath()
        {
            List<StructPoint3D> loadPath = new List<StructPoint3D>();

            try
            {
                StreamReader reader = new StreamReader(@"../../PathFile.txt");

                using (reader)
                {
                    string line = reader.ReadLine();
                    while (line != null)
                    {
                        StructPoint3D point = new StructPoint3D();
                        string[] points = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        point.X = double.Parse(points[0]);
                        point.Y = double.Parse(points[1]);
                        point.Z = double.Parse(points[2]);
                        loadPath.Add(point);
                        line = reader.ReadLine();
                    }
                }
            }

            catch (DirectoryNotFoundException)
            {
                Console.WriteLine("The file path contains a directory that cannot be found!");
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("The file was not found!");
            }
            catch (ArgumentNullException)
            {
                Console.WriteLine("No file path is given!");
            }
            catch (ArgumentException)
            {
                Console.WriteLine("The entered file path is not correct!");
            }
            catch (PathTooLongException)
            {
                Console.WriteLine("The entered file path is too long - 248 characters are the maximum!");
            }
            catch (UnauthorizedAccessException uoae)
            {
                Console.WriteLine(uoae.Message);
            }
            catch (SecurityException)
            {
                Console.WriteLine("You don't have the required permission to access this file!");
            }
            catch (NotSupportedException)
            {
                Console.WriteLine("Invalid file path format!");
            }
            catch (IOException ioe)
            {
                Console.WriteLine(ioe.Message);
            }
            return loadPath;
        }