public static List<Path> LoadPath(string filePath)
        {
            StreamReader reader = new StreamReader(string.Empty + filePath + string.Empty);
            List<Path> collectionOfPathsFromText = new List<Path>();
            string input = "Start";
            using (reader)
            {
                while (input != string.Empty)
                {
                    input = reader.ReadLine();
                    Path newPathFromText = new Path();
                    while (input != "End of Path" && input != "Start" && input != null)
                    {
                        Point3D currentPoint = new Point3D();
                        double[] pointCoord = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(double.Parse).ToArray();
                        currentPoint.PointX = pointCoord[0];
                        currentPoint.PointY = pointCoord[1];
                        currentPoint.PointZ = pointCoord[2];
                        newPathFromText.PointsCollection.Add(currentPoint);
                        input = reader.ReadLine();
                    }

                    if (input == null)
                    {
                        break;
                    }

                    collectionOfPathsFromText.Add(newPathFromText);
                }

                return collectionOfPathsFromText;
            }
        }
Пример #2
0
 static void Main()
 {
     Point3D point1 = new Point3D(1, 1, 1);
     Point3D point2 = new Point3D(2.5, -0.4, 12.09);
     Console.WriteLine(point1);
     Console.WriteLine(point2);
 }
Пример #3
0
        public static void Main()
        {
            // Prints the center of the coordinate system
            Console.WriteLine("The center of coordinate system is: O({0})", Point3D.O);

            // Creates some point A
            var pointA = new Point3D(3, 7, -2);
            Console.WriteLine("Point A ({0})", pointA);

            // Defines some list of points from a text file "input.txt"
            var points = PathStorage.LoadPath(@"..\..\input.txt");
            points.Add(new Point3D(4, 5, 6));

            // Prints the distance between two points in 3D space
            if (points.Count() >= 2)
            {
                Console.WriteLine("\nDistance between point B and point C: " + Distance.D(points.Points[0], points.Points[1]));
            }

            // Clears all points in the path
            points.Clear();

            // Saves the path with all points to a text file "output.txt"
            PathStorage.SavePath(points);

            points.Add(new Point3D(4, 5, 6));
            points.Add(new Point3D(7, 1, -6));
            points.Add(new Point3D(92, 54, 65));

            // Removes the 2nd point
            points.RemoveAt(1);

            PathStorage.SavePath(points);
        }
Пример #4
0
        public static void Main()
        {
            Point3D point1 = new Point3D(0.0, -3.0, 10.15);

            Console.WriteLine(point1);
            Console.WriteLine(Point3D.StartingPoint);
        }
Пример #5
0
        static void Main()
        {
            //Printing BasePoint
            Console.Write("Starting Point: ");
            Console.WriteLine(Point3D.BasePoint);

            // Testing EucledeanDistance
            Point3D randomPoint = new Point3D(2.65, 4.56, 8.26);
            double distance = Distance.EucledeanDistance(Point3D.BasePoint, randomPoint);
            Console.WriteLine("Distance between {0} and {1} = {2:F2}", Point3D.BasePoint, randomPoint, distance);

            // Testing Path storage
            // Uncomment this code to test Path Saving
            //Path testPath = new Path();
            //testPath.AddPoint(Point3D.BasePoint);
            //testPath.AddPoint(randomPoint);
            //testPath.AddPoint(new Point3D(4.3, -2.2, 6.25));

            //PathStorage.SavePath(testPath);

            Console.WriteLine(new String('-', 30));
            Console.WriteLine("Printing Loaded Path:");
            Path loadedPath = PathStorage.LoadPath();
            loadedPath.PrintPath();

        }
Пример #6
0
 public static double Points3D(Point3D first, Point3D second)
 {
     double result = Math.Sqrt(
         (first.XCoord - second.XCoord) * (first.XCoord - second.XCoord) +
         (first.YCoord - second.YCoord) * (first.YCoord - second.YCoord) +
         (first.ZCoord - second.ZCoord) * (first.ZCoord - second.ZCoord));
     return result;
 }
 public static double Distance(Point3D a, Point3D b)
 {
     double distance=0;
     distance=Math.Sqrt(Math.Pow(b.PointX-a.PointX,2)+
         Math.Pow(b.PointY-a.PointY,2)+
         Math.Pow(b.PointZ-a.PointZ,2));
     return distance;
 }
Пример #8
0
        static void Main(string[] args)
        {
            Point3D myPoint = new Point3D(1, 2, 3);
            Path.AddPoint(myPoint);
            Path.AddPoint(new Point3D(2, 3, 7));
            Path.AddPoint(new Point3D(9, 2, 2));
            Path.AddPoint(new Point3D(2, 7, 1));

            PathStorage.SavePaths("../../text.txt");
            Console.WriteLine(PathStorage.LoadPaths("../../text.txt"));

            GenericList<int> array = new GenericList<int>(10);

            array.Add(4);
            array.Add(6);
            array.Add(8);
            array.Add(3);
            array.Add(7);
            array.Add(1);

            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine(array[i]);
            }

            Console.WriteLine();
            array.Remove(2);

            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine(array[i]); 
            }

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

            Console.WriteLine("Max element is: " + array.Max());
            Console.WriteLine(new string('-', 20));

            Type type = typeof(Program);
            
            object[] allAttibutes = type.GetCustomAttributes(false);
            foreach (VersionAttribute attribute in allAttibutes)
            {
                Console.WriteLine("Version is: " + attribute.Value);
            }
        }
Пример #9
0
        static void Main()
        {
            Point3D point3D = new Point3D(1, 2, 3);
            Point3D anotherPoint3D = new Point3D(3, 2, 1);
            Console.WriteLine(point3D);
            Console.WriteLine(Point3D.ZeroCoord);

            Console.WriteLine(Distance.Points3D(point3D, Point3D.ZeroCoord));
            Console.WriteLine(Distance.Points3D(point3D, anotherPoint3D));

            Path firstPath = new Path();
            firstPath = PathStorage.LoadPath();
            Console.WriteLine("-----print path-----");
            firstPath.PrintPath();
            Console.WriteLine("-----end-----");

            PathStorage.SavePath(firstPath);
        }
Пример #10
0
 public List<Point3D> AddPath()
 {
     Console.WriteLine("Enter the number of points which you want to add:");
     List<Point3D> ListOfPoints = new List<Point3D>();
     int number = int.Parse(Console.ReadLine());
     //Path newPath = new Path();
     for (int i = 0; i < number; i++)
     {
         Console.WriteLine("Enter X for the new point:");
         double newPointX = double.Parse(Console.ReadLine());
         Console.WriteLine("Enter Y for the new point:");
         double newPointY = double.Parse(Console.ReadLine());
         Console.WriteLine("Enter Z for the new point:");
         double newPointZ = double.Parse(Console.ReadLine());
         Point3D newPoint = new Point3D(newPointX, newPointY, newPointZ);
         ListOfPoints.Add(newPoint);
     }
     return ListOfPoints;
 }
Пример #11
0
 public static Path LoadPath()
 {
     Path result = new Path();
     using (StreamReader reader = new StreamReader("..//..//LoadPaths.txt"))
     {
         char[] separators = { ',', '(', ')', ' ' };
         string line = reader.ReadLine();
         while (line != null)
         {
             Point3D point = new Point3D();
             string[] points = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
             point.XCoord = int.Parse(points[0]);
             point.YCoord = int.Parse(points[1]);
             point.ZCoord = int.Parse(points[2]);
             result.AddPoint(point);
             line = reader.ReadLine();
         }
     }
     return result;
 }
Пример #12
0
        public static void CreatePoint()
        {
            Console.WriteLine("Examplary points");
            Point3D pointInput1 = new Point3D(-7, -4, 3);
            Point3D pointInput2 = new Point3D(17, 6, 2.5);
            Console.WriteLine("Point A:");
            Console.WriteLine(pointInput1);
            Console.WriteLine("Point B:");
            Console.WriteLine(pointInput2);
            double distance = DistanceCalculation.Distance(pointInput1, pointInput2);
            Console.WriteLine("The distance between point A and point B is:");
            Console.WriteLine(distance);
            string filePath = "../../Paths.txt";

            List<Path> listOfPaths = new List<Path>();
            while (true)
            {
                Console.WriteLine("Do you want to create a new path:");
                string input = Console.ReadLine();
                if (input == "Yes")
                {
                    Path newPath = new Path();
                    newPath.PointsCollection = newPath.AddPath();
                    listOfPaths.Add(newPath);

                    PathStorage.SavePath(filePath, listOfPaths);
                }
                else
                {
                    break;
                }
            }

            Console.WriteLine("The text files paths.txt is in the folder called \"Structure\".");

            // The paths from the text file are here:
            List<Path> listOfRecordedPaths = PathStorage.LoadPath(filePath);
        }
Пример #13
0
 // Adds a new point in the path
 public void Add(Point3D point)
 {
     this.Points.Add(point);
 }
Пример #14
0
 public void AddPoint(Point3D point)
 {
     this.AllPoints.Add(point);
 }
Пример #15
0
 public void AddPoint(Point3D newPoint)
 {
     this.pointsCollection.Add(newPoint);
 }
Пример #16
0
 public void RemovePoint(Point3D pointForRemoving)
 {
     this.pointsCollection.Remove(pointForRemoving);
 }
 public static double CalculateDistance(Point3D firstPoint, Point3D secondPoint)
 {
     return Math.Sqrt(Math.Pow((firstPoint.X - secondPoint.X), 2) + Math.Pow((firstPoint.Y - secondPoint.Y), 2) + Math.Pow((firstPoint.Z - secondPoint.Z), 2));
 }
Пример #18
0
 static Point3D()
 {
     startingPoint = new Point3D(0, 0, 0);
 }
Пример #19
0
 public static void AddPoint(Point3D point)
 {
     points.Add(point);
 }
Пример #20
0
 public void AddPoint(Point3D point)
 {
     Paths.Add(point);
 }
Пример #21
0
 /// <summary>
 /// Calculates the distance between two points in the 3D space.
 /// </summary>
 /// <param name="a">The first point A.</param>
 /// <param name="b">The second point B.</param>
 /// <returns>Returns the distance between the points.</returns>
 public static double D(Point3D a, Point3D b)
 {
     return Math.Sqrt(Math.Pow(a.X - b.X, 2) + Math.Pow(a.Y - b.Y, 2) + Math.Pow(a.Z - b.Z, 2));
 }
Пример #22
0
 //P2
 static Point3D()
 {
     o = new Point3D(0, 0, 0);
 }
Пример #23
0
 public void AddPoint(Point3D newPoint)
 {
     this.listOfPoints.Add(newPoint);
 }
Пример #24
0
 public static void Main()
 {
     Point3D point1 = new Point3D(-7, -4, 3);
     Point3D point2 = new Point3D(17, 6, 2.5);
     Console.WriteLine(DistanceCalculator.CalculateDistance(point1, point2));
 }
Пример #25
0
 // P2
 static Point3D()
 {
     Center = new Point3D(0, 0, 0);
 }
Пример #26
0
 public static double EucledeanDistance(Point3D a, Point3D b)
 {
     double distance = Math.Sqrt(Math.Pow(a.X - b.X, 2) + Math.Pow(a.Y - b.Y, 2) + Math.Pow(a.Z - b.Z, 2));
     return distance;
 }
Пример #27
0
 public void RemovePoint(Point3D pointForRemoving)
 {
     this.listOfPoints.Remove(pointForRemoving);
 }