Exemplo n.º 1
0
 public static double DistanceBetween(Point3d point1, Point3d point2)
 {
     double distance = Math.Sqrt(Math.Pow((point2.PointX - point1.PointX), 2) +
                                 Math.Pow((point2.PointY - point1.PointY), 2) +
                                 Math.Pow((point2.PointZ - point1.PointZ), 2));
     return distance;
 }
Exemplo n.º 2
0
Arquivo: Main.cs Projeto: rsmont/OOP
        static void Main(string[] args)
        {
            Point3d pointOne = new Point3d();

            pointOne.PointX = 0.5;
            pointOne.PointY = 0.5;
            pointOne.PointZ = 0.5;
            Console.WriteLine(pointOne);
            Console.WriteLine(Point3d.ZeroPosition);
            Point3d pointTwo = new Point3d(1.5, 1.5, 1.5);

            Console.WriteLine(pointTwo);
            Console.WriteLine("Distance between");
            Console.WriteLine(Distance.DistanceBetween(pointOne, pointTwo));

            Path path = new Path();
            path.Add(pointOne);
            path.Add(pointTwo);
            PathStorage.SavePath(path, @"../../Points3d.txt");
            path.Clear();
            Console.WriteLine();
            Console.WriteLine("Path is saved and then cleared");

            path = PathStorage.LoadPath(@"../../Points3d.txt");
            Console.WriteLine();
            Console.WriteLine("After reloading again from file");
            Console.WriteLine();
            foreach (var item in path.Paths)
            {
                Console.WriteLine(item);
            }
        }
Exemplo n.º 3
0
 public static Path LoadPath(string filePath)
 {
     Path tempPath = new Path();
     Point3d point = new Point3d();
     using (var reader = new StreamReader(filePath))
     {
         int i = 0;
         for (string line; (line = reader.ReadLine()) != null; i++)
         {
             string[] points = line.Split(',');
             point.PointX = double.Parse(points[0]);
             point.PointY = double.Parse(points[1]);
             point.PointZ = double.Parse(points[2]);
             tempPath.Add(point);
         }
     }
     return tempPath;
 }