示例#1
0
        static void Main()
        {
            Point3D firstPoint = new Point3D(45, 3, 12);
            var     distance   = DistanceBetweenPoints.CalcDistance(firstPoint, Point3D.StartCoordinates);

            Console.WriteLine("The distance between the two points is {0}\n", distance);

            PathStorage.LoadPath();
            Console.WriteLine("Calling sequence of points from a txt file\n" + new string('=', 60));
            foreach (var item in Path.Points)
            {
                Console.WriteLine(item);
            }
        }
示例#2
0
        static void Main()
        {
            // Test task 1
            Point3D p = new Point3D();

            p.X = 4;
            p.Y = 3;
            Console.WriteLine(p.ToString());

            // Test task 2
            Console.WriteLine(p.ZeroPoint);

            // Test task 3
            DistanceIn3D dist = new DistanceIn3D();

            Console.WriteLine(dist.CalcDistance(p, p.ZeroPoint));
            Point3D p2 = new Point3D(4, 6, 2);

            Console.WriteLine(dist.CalcDistance(p, p2));

            // Test task 4
            Path path = new Path();

            path.Add(p);
            path.Add(0, p2);
            path.Add(new Point3D(9, 5, 9));
            path.Add(new Point3D(4, -6, -3));
            path.Add(3, new Point3D(2, -5, 8));
            List <Path> paths = new List <Path>();

            paths.Add(path);

            Path secondPath = new Path();

            secondPath.Add(new Point3D(1, 2, -7));
            secondPath.Add(p2);
            secondPath.Add(0, p);
            secondPath.Add(new Point3D(-4, 4, -3));
            secondPath.Add(2, new Point3D(3, 6, 9));
            paths.Add(secondPath);
            PathStorage.SaveToFile(paths, @"../../File with Path.txt");
            List <Path> loadedPaths = PathStorage.LoadFromFile(@"../../File with Path.txt");

            Console.WriteLine("Paths for save");
            printPaths(paths);
            Console.WriteLine("Loaded paths");
            printPaths(loadedPaths);
        }
示例#3
0
        static void Main()
        {
            Point3D pointOne = new Point3D(10, 15, 20);
            Point3D pointTwo = new Point3D(1, 2, 3);

            Console.WriteLine("Point 1 " + pointOne);
            Console.WriteLine("Point 2 " + pointTwo);
            Console.WriteLine("Point zero " + Point3D.PointZero);

            var distance = DistanceCalculator.Calculate(pointOne, pointTwo);

            Console.WriteLine("Distance between {0} and {1} is {2:F2}", pointOne, pointTwo, distance);

            const string fileName = "StorageTest";

            Path path = new Path();

            path.AddPoints(pointOne, pointTwo);
            PathStorage.Save(path, fileName);
            PathStorage.Load(fileName);
            Console.WriteLine(path);
            Console.WriteLine(PathStorage.Load("test"));
        }
示例#4
0
        public static void LoadPath()
        {
            PathStorage.SavePath();

            StreamReader reader = new StreamReader(pathStorage);
            string       line;

            using (reader)
            {
                while ((line = reader.ReadLine()) != null)
                {
                    var separators = new char[] { ' ', ',', '{', '}', '(', ')' };
                    var pointArray = line.Split(separators, StringSplitOptions.RemoveEmptyEntries)
                                     .Select(double.Parse)
                                     .ToArray();

                    double X = pointArray[0];
                    double Y = pointArray[1];
                    double Z = pointArray[2];

                    Path.AddPoint(new Point3D(X, Y, Z));
                }
            }
        }