Пример #1
0
        static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            var pointsSequence = new Path();

            Point3D firstPoint3D = new Point3D(1.2, 2.4, 3.7);
            pointsSequence.AddPoint(firstPoint3D);
            Console.WriteLine("Point({0})", firstPoint3D);

            Point3D secondPoint3D = Point3D.StartPoint;
            pointsSequence.AddPoint(secondPoint3D);
            Console.WriteLine("Point({0})", secondPoint3D);

            Console.WriteLine("Distance between the points: {0:F2}", Distance.CalcDistance(firstPoint3D, secondPoint3D));

            pointsSequence.RemovePoint(firstPoint3D);
            pointsSequence.RemovePoint(secondPoint3D);

            Path path3D = new Path();

            string[] points = File.ReadAllText(@"..\..\input.txt").Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            File.WriteAllText(@"..\..\output.txt", string.Empty);

            Console.WriteLine("\nPoints loaded from input.txt");
            int index = 0;
            while (index < points.Length)
            {
                double[] coordinates = points[index].Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries)
                                                .Select(double.Parse)
                                                .ToArray();
                path3D.AddPoint(new Point3D(coordinates[0], coordinates[1], coordinates[2]));
                Console.WriteLine("{0}", path3D.PointsSequence[index]);
                File.AppendAllText(@"..\..\output.txt", points[index] + Environment.NewLine);
                index++;
            }

            Console.WriteLine("Points saved to output.txt\n");
        }
Пример #2
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");
        }