Пример #1
0
        static void Main()
        {
            Point3D point1 = new Point3D(1.5, 2.5, 3.5); //creating points for testing purposes
            Point3D point2 = new Point3D(-1, -4, 7);
            Point3D point3 = new Point3D(1, 2, 3);
            Point3D point4 = new Point3D(-1, -2, 3);
            Point3D point5 = new Point3D(1.25, 2.375, 3.8);

            Path testPath = new Path(); //creating a path of points for testing purposes

            testPath.AddPoint(point1);
            testPath.AddPoint(point2);
            testPath.AddPoint(point3);
            testPath.AddPoint(point4);
            testPath.AddPoint(point5);

            PathStorage.SavePath(testPath, "test"); //saving the test points to the file "test.txt"

            Console.WriteLine("Test file has been created");

            Console.WriteLine(new string('-', 50));

            Path loadedPath = PathStorage.LoadPath(@"../../test.txt"); //loading the saved file and printing the points

            for (int i = 0; i < loadedPath.PointSequence.Count; i++)
            {
                Console.WriteLine(loadedPath.PointSequence[i]);
            }
        }
Пример #2
0
        static void Main()
        {
            // 1.Create a structure Point3D to hold a 3D-coordinate {X, Y, Z} in the Euclidian 3D space.
            //Implement the ToString() to enable printing a 3D point.

            Point3D RandomPoint = new Point3D(1, 2, 3);
            Console.WriteLine("Random Point:");
            Console.WriteLine(RandomPoint.ToString());

            // 2. Add a private static read-only field to hold the start of the coordinate system – the point O{0, 0, 0}.
            // Add a static property to return the point O.
            Console.WriteLine("Starting Point O:");
            Console.WriteLine(Point3D.StartPoint());

            //3 Write a static class with a static method to calculate the distance between two points in the 3D space.
            Point3D PointA = new Point3D(1, 2, 3);
            Point3D PointB = new Point3D(4, 5, 6);
            Console.WriteLine("Calculate Distance between two points: ");
            Console.WriteLine(CalculationDistance.Distance(PointA, PointB));

            //4 Create a class Path to hold a sequence of points in the 3D space.
            //Create a static class PathStorage with static methods to save and load paths from a text file. Use a file format of your choice.
            Path pathList = new Path();
            pathList.path.Add(PointA);
            pathList.path.Add(PointB);
            Console.WriteLine("First point of sequence of points");
            Console.WriteLine(pathList.path[0]);
            //Save and load
            PathStorage.SavePath(pathList);
            Path LoadedList = PathStorage.LoadPath("../../path.txt");
        }
Пример #3
0
        public static void Main(string[] args)
        {
            Point top = new Point(1, 100, 1);
            Console.WriteLine(top);

            Point zero = Point.ZeroPoint;
            Console.WriteLine(zero);

            Point thirth = new Point(1, 1, 200);
            Console.WriteLine(thirth);
            Console.WriteLine();

            Console.WriteLine("-------------Old Path----------");
            var path = new Path(top);
            path.Add(zero);
            path.Add(thirth);
            Print(path.Points);

            PathStorage.Save("path.txt", path);

            Console.WriteLine();
            var newPath = PathStorage.Load("path.txt");
            Console.WriteLine("--------New Path----------------");
            Print(newPath.Points);
        }
Пример #4
0
        public static void Main()
        {
            //test struct 3D
            Point3D point = new Point3D(1, 2, 3);
            Point3D pointTwo = new Point3D(4, 5, 6);
            double distBtw2Poins = CalculateDistance.CalcDist(point, pointTwo);
            Console.WriteLine("The distance between 2 point is {0}",distBtw2Poins);

            //testing PathStorage
            //write
            Path pathToWrite = new Path();

            pathToWrite.AddPoint(point);
            pathToWrite.AddPoint(pointTwo);
            PathStorage.SavePath(pathToWrite);
            Console.WriteLine();
            Console.WriteLine("Check the project folder for saved file.");
            Console.WriteLine();

            //read
            List<Path> readedPath = PathStorage.LoadPath();
            Console.WriteLine("This is the points from readed file:" );

            foreach (var path in readedPath)
            {

                foreach (var pointers in path.PathOfPoints)
                {
                    Console.WriteLine(pointers);
                }

            }
        }
Пример #5
0
        static void Main()
        {
            /*наясно съм че "Point3D ex1-ex2-ex3-ex4" не е добро наименование на проект,
             * правилно е да е "Point3D", добавих единствено това "ex1-ex2-ex3-ex4",
             * за да е прегледно за проверяващия кои задачи обхваща от домашното*/

            string fileName = @"../../../paths.txt";
            //string fileName = "c://test//path.txt";  //wrong path

            //ex.1
            Point3D point = new Point3D(3, 5, 7);
            Console.WriteLine(point.ToString());

            //ex.2 print zero point
            Point3D point1 = Point3D.Zero;
            Console.WriteLine(point1.ToString());

            //ex.3 print distance between two points
            Console.WriteLine("The distance between two pints is: {0:F8}", DistanceIn3DSpace.CalculateDistanceBetweenTwoPoints(point, point1));

            //ex.4 add point in path
            Path pathOfPoints = new Path();
            pathOfPoints.AddPoint(point);
            pathOfPoints.AddPoint(point1);

            //write paths in file
            PathStorage.SavePathsInFile(pathOfPoints, fileName);

            //load paths from file
            Path pathOfPointsLoad = new Path();
            pathOfPointsLoad = PathStorage.LoadPathsFromFile(fileName);

            Console.WriteLine("Print points from pathOfPointsLoad");
            pathOfPointsLoad.PrintPaths();
        }
Пример #6
0
        static void Main()
        {
            //Create new point
            Point3D myPoint = new Point3D(2, 3, 4);
            Console.WriteLine(myPoint);
            Console.WriteLine(Point3D.Point0);

            //Calculate distance between two points
            double distance = PointCalculations.Point3DDistance(Point3D.Point0, myPoint);
            Console.WriteLine(distance);

            //Create new path and add elements
            Path testPath = new Path(myPoint);
            testPath.AddToPath(Point3D.Point0);

            //Save path in file
            PathStorage.SaveInFile(testPath);

            //Create new path and add points from file
            Path readTest = new Path();
            readTest = PathStorage.ReadFromFile();
            //Print readed from file points
            List<Point3D> points = new List<Point3D>();
            points = readTest.GetAllPathElements();
            foreach (var item in points)
            {
                Console.WriteLine(item);
            }
        }
Пример #7
0
        static void Main()
        {
            Path pointsPath = new Path();

            pointsPath.AddPoint(new Point(1.32, 2.22, 3.12));
            pointsPath.AddPoint(new Point(3.32, 2.22, 1.12));
            pointsPath.AddPoint(new Point(4.31, 5.22, 6.13));
            pointsPath.AddPoint(new Point(5.37, 4.28, 3.19));

            Console.WriteLine(Point.StartingPoint);
            Console.WriteLine(DistanceCalculator.CalcDistance(pointsPath.Points[0], pointsPath.Points[1]));
            foreach (var point in pointsPath.Points)
            {
                Console.WriteLine(point.ToString());
            }

            string fileLocation = "../../path";
            Storage.WriteToBinaryFile(fileLocation, pointsPath);

            Console.WriteLine("\r\nPoints from file:");
            Path pathFromFile = Storage.ReadFromBinaryFile<Path>(fileLocation);
            foreach (var point in pathFromFile.Points)
            {
                Console.WriteLine(point.ToString());
            }
        }
Пример #8
0
        public static void Main()
        {
            // Adding some paths to save in file
            Point3D path = new Point3D(1, 4, 7);
            Path current = new Path();

            current.AddPath(path);

            path = new Point3D(1, 74, 78);
            current.AddPath(path);

            path = new Point3D(18, 14, 8);
            current.AddPath(path);

            path = new Point3D(100, 84, 47);
            current.AddPath(path);

            path = new Point3D(47, 94, 0);
            current.AddPath(path);

            PathStorage.SavePath(current);

            Console.WriteLine("The paths are saved in PathSave.txt");

            // Uncomment the foreach cycle in PathStorage.cs to print the path readed from PathLoad.txt
            PathStorage.LoadPath();
        }
Пример #9
0
        static void Main(string[] args)
        {
            Structure3D firstPoint = new Structure3D(1, 2, 3);
            Structure3D secondPoint = new Structure3D(0, 8, 1);

            Path firstPath = new Path();
            firstPath.AddPoint(firstPoint);
            firstPath.AddPoint(secondPoint);

            PathStorage.SavePaths(firstPath);
            List<Path> pathList = PathStorage.ReadPaths();
        }
Пример #10
0
        public static void Test4()
        {
            Path test1 = new Path();
            test1.AddPoint();
            test1.AddPoint(new Point(1, 2, 3));
            test1.AddPoint(4, 5, 6);

            Console.WriteLine(test1); // testing toString for a path

            PathStorage.WritePathToFile("testing.txt", test1);

            Path readFromFile = PathStorage.ReadPathFromFile("readMe.txt");

            Console.WriteLine(readFromFile);
        }
        static void Main()
        {
            Point3D point = new Point3D(-7, -4, 3);                   // Creates two points
            Point3D pointtwo = new Point3D(17, 6, 2.5);               //
            Path path = new Path();                                   // Creates a path

            Console.WriteLine(Point3D.Start);                         // Prints starting point of the coordination system
            Console.WriteLine(Distance.Calculate(point, pointtwo));   // Prints distance between points

            PathStorage.Load(path);                                   // Loads points into path

            Console.WriteLine(path);                                  // Prints path

            PathStorage.Save(path);                                   // Saves the path back to the file
        }
Пример #12
0
        static void Main()
        {
            Structure3DPoint pointA = new Structure3DPoint();
            Structure3DPoint pointB = new Structure3DPoint(1,1,1);
            double distance = 0;
            Console.WriteLine(pointB);
            Console.WriteLine(Structure3DPoint.Point0);

            distance = Distance.FindDistance(pointA, pointB);
            Console.WriteLine(distance);

            Path space = new Path(pointA, pointB);

            PathStorage.SavePath("../../SavePath.txt", space);

            Path loadPath = new Path();

            loadPath = PathStorage.LoadPath("../../LoadPath.txt");
            PathStorage.SavePath("../../NewPath", loadPath);
        }
        public static void Main(string[] args)
        {
            Path p = new Path();
            p.Add(new Point3D(1, 2, 3));
            p.Add(new Point3D(2, 2, 2));

            PathStorage.SavePath(p, "path1.txt");

            Path p2 = PathStorage.LoadPath("path1.txt");

            if (p2 != null)
            {
                for (int i = 0; i < p2.Count; i++)
                {
                    Console.WriteLine(p2[i]);
                }

                Console.WriteLine("Distance: ");
                Console.WriteLine(Distance.FindDistance(p2[0], p2[1]));
            }
        }
Пример #14
0
        static void Main(string[] args)
        {
            // Examples
            Point3D p1 = new Point3D(5.4, 6.2, 3);
            Point3D p2 = new Point3D(7.9, 2.1, 5.9);
            Point3D p3 = new Point3D(23.4, 3, 5);
            Point3D p4 = new Point3D(7, 15.5, 57.7);

            // Create sequence of points ( List<Point3D> )
            Path points = new Path();

            Console.WriteLine("The Path of 3D points is created.\n");

            // Add points in the sequence
            Console.WriteLine("Adding some 3D points...");
            points.AddPoint(p1);
            points.AddPoint(p2);
            points.AddPoint(p3);
            points.AddPoint(p4);
            Console.WriteLine(points);

            //Remove some points
            Console.WriteLine("\nRemoving first and last 3D point from tha Path...\n");
            points.RemovePoint(p1);
            points.RemovePoint(p4);

            Console.WriteLine("Now the Path contains:");
            Console.WriteLine(points.ToString());

            // Calculate distance between two 3D points
            Console.WriteLine("\nCalculate the distance between two 3D points:\n");
            Console.WriteLine("{0:F2} cm", DistanceCalculator.CalculateDistance(p2, p3));

            // Save points into text file
            PathStorage.SavePaths(points, "PointsFromText.txt");
            Console.WriteLine("\nThe Path of 3D Points is saved in text file.");
            Console.WriteLine("You can find it at: Current Project\\bin\\Debug\\PointsFromText.txt");
        }