Ejemplo n.º 1
0
        public static void Main()
        {
            // set and print test Point3D
            Point3D testPoint = new Point3D(1, 2, 3);

            System.Console.WriteLine(testPoint);

            // set test Path
            Path testPath = new Path();

            testPath.AddPionts(new Point3D(1, 1, 1), new Point3D(2, 2, 2), new Point3D(3, 3, 3), new Point3D(4, 4, 4));

            // print test Path
            Console.WriteLine();
            Console.WriteLine(testPath);

            // saves the test Path to "..\..\testPath.txt"
            PathStorage.SavePath(testPath, "testPath");

            // load currently saved test Path from "..\..\testPath.txt"
            Path loadedPath = PathStorage.LoadPath("testPath");

            // print loaded Path
            Console.WriteLine();
            Console.WriteLine(loadedPath);
        }
Ejemplo n.º 2
0
        static void Main()
        {
            Point3D first  = new Point3D(1, 2, 3);
            Point3D second = new Point3D(1, 2, 4);
            Point3D third  = new Point3D(-1.5, 14, 4);
            Point3D fourth = new Point3D(3, 2, 1);

            double distance = DistanceCalculator.CalculateDistance(first, second);

            Console.WriteLine("Distance between points {0} and {1} is: {2}\n",
                              first, second, distance);

            Path somePath = new Path();

            somePath.AddPointsToPath(Point3D.Point0, first, second, third);
            somePath.AddPointToPath(fourth);

            PathStorage.SavePath(filePath, somePath);

            try
            {
                Path loadedPath = PathStorage.LoadPath(filePath);
                Console.WriteLine("The path loaded from file {0} is:", System.IO.Path.GetFullPath("PathTest.txt"));
                Console.WriteLine(loadedPath);
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("File was not found.");
            }
        }
Ejemplo n.º 3
0
        static void Main()
        {
            //set two 3D points
            Point3D firstPoint  = new Point3D(1, 2, 3);
            Point3D secondPoint = new Point3D(4, 5, 6);

            //make instanse of Path Object and add three points to it.
            Path pointSequence = new Path();

            pointSequence.AddToPath(firstPoint);
            pointSequence.AddToPath(secondPoint);
            //using static property O which retursn (0,0,0)
            pointSequence.AddToPath(firstPoint.O);

            //Get the path of points by GetPath method which returns List<Point3D> and print the path
            var path = new List <Point3D>();

            path = pointSequence.GetPath();
            foreach (var point in path)
            {
                Console.WriteLine(point);
            }

            //Add new line in the PointCollection.txt  file
            string filePath = @"..\..\PointCollection.txt";

            PathStorage.SaveToPath(filePath, firstPoint);

            //Calculate the distanse between two 3D points
            Console.WriteLine("Distance = " + VectorMagnitude3D.MagnitudeByPoints(firstPoint, secondPoint));

            //Load and display the content of the file PointCollection.txt
            var fileContent = PathStorage.LoadPath(filePath);

            foreach (var line in fileContent)
            {
                Console.WriteLine(line);
            }
        }