Ejemplo n.º 1
0
        public static void Main()
        {
            var point = new Point3D(3.5, 4, 12);

            Console.WriteLine(point);
            Console.WriteLine(Point3D.StartPoint);
        }
Ejemplo n.º 2
0
        public static Path3D LoadPath(string destination)
        {
            List<Point3D> points = new List<Point3D>();
            using (StreamReader reader = new StreamReader(destination))
            {
                while (true)
                {
                    string line = reader.ReadLine();
                    if (string.IsNullOrEmpty(line))
                    {
                        break;
                    }

                    string[] pointCoordinates = line.Split(' ');
                    double x = double.Parse(pointCoordinates[0]);
                    double y = double.Parse(pointCoordinates[1]);
                    double z = double.Parse(pointCoordinates[2]);

                    Point3D point = new Point3D(x, y, z);
                    points.Add(point);
                }

                Path3D path = new Path3D(points.ToArray());

                return path;
            }
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            Point3D startPoint = Point3D.StartPoint;
            Point3D pointA = new Point3D(3.5, 4.2, 8);
            Point3D pointB = new Point3D(1, 17, 4.8);
            Point3D pointC = new Point3D(4.8, 1, 2);

            Path3D path = new Path3D(startPoint, pointA, pointB, pointC);

            try
            {
                Storage.SavePath(path, "path.txt");
            }
            catch (IOException ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                Path3D pathLoaded = Storage.LoadPath("path.txt");
                Console.WriteLine(path);
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 4
0
        public static double CalculateDistance(Point3D first, Point3D second)
        {
            double distance = Math.Sqrt(((first.X - second.X) * (first.X - second.X)) +
                                        ((first.Y - second.Y) * (first.Y - second.Y)) +
                                        ((first.Z - second.Z) * (first.Z - second.Z)));

            return distance;
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            var firstPoint = new Point3D(3.5, 12, 1.5);
            var secondPoint = new Point3D(4.2, 5.2, 3.2);

            double distance = DistanceCalculator.CalculateDistance(firstPoint, secondPoint);
            Console.WriteLine("{0:0.00}", distance);

            distance = DistanceCalculator.CalculateDistance(firstPoint, Point3D.StartPoint);
            Console.WriteLine("{0:0.00}", distance);
        }