Esempio n. 1
0
        static void Main(string[] args)
        {
            string destination = ""; ///<----------- PUT YOUR OWN PATH/DESTINATION FILE HERE

            //creating a point from the 3DPoint class
            _01_3DPoint point = new _01_3DPoint(0, 1, 3);

            //creating a pathsList from the 3DPaths class
            _03_3DPaths paths = new _03_3DPaths();

            //calculating distance between a 3D point and StartingPoint
            Console.WriteLine(_02_DistanceCalculator.DistanceCalc3D(point, _01_3DPoint.StartingPoint));

            //utilising some methods of the 3DPaths class
            paths.AddPointToPath(point);
            paths.AddPointToPath(_01_3DPoint.StartingPoint);

            //utilising the SavePathTo method from the Storage class
            _03_Storage.SavePathTo(paths, destination);

            //utilising the LoadPathFrom method from the Storage class
            _03_3DPaths puteki = _03_Storage.LoadPathFrom(destination);

            for (int i = 0; i < puteki.Points.Count; i++)
            {
                Console.WriteLine(puteki.Points[i].ToString());
            }
        }
Esempio n. 2
0
        public static double DistanceCalc3D(_01_3DPoint pointOne, _01_3DPoint pointTwo)
        {
            double deltaX = pointTwo.X - pointOne.X;
            double deltaY = pointTwo.Y - pointOne.Y;
            double deltaZ = pointTwo.Z - pointOne.Z;

            double distance = Math.Sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);

            return(distance);
        }
        public static _03_3DPaths LoadPathFrom(string destination)
        {
            _03_3DPaths paths = new _03_3DPaths();
            FileStream  fs    = new FileStream(destination, FileMode.Open);

            using (StreamReader reader = new StreamReader(fs))
            {
                string line = reader.ReadLine();
                while (line != null)
                {
                    line = Regex.Replace(line, @"\D+", " ");
                    string[]    vertices = line.Trim().Split();
                    _01_3DPoint point    = new _01_3DPoint(int.Parse(vertices[0]), int.Parse(vertices[1]), int.Parse(vertices[2]));
                    paths.AddPointToPath(point);
                    line = reader.ReadLine();
                }
            }
            return(paths);
        }
Esempio n. 4
0
 public void AddPointToPath(_01_3DPoint point)
 {
     this.points.Add(point);
 }