public static void Main()
        {
            Point3D p1 = new Point3D(-7, -4, 3);
            Point3D p2 = new Point3D(17, 6, 2.5);

            Console.WriteLine("d = " + DistanceCalc(p1, p2));
        }
Exemplo n.º 2
0
        public static Path3D LoadFromFile(string fileName)
        {
            Path3D path = new Path3D();

            using (StreamReader reader = new StreamReader(fileName))
            {
                string input = reader.ReadToEnd();
                const string Pattern = "{([\\d,.]+), ([\\d,.]+), ([\\d,.]+)}";

                var regx = new Regex(Pattern);
                var matches = regx.Matches(input);
                if (matches.Count <= 0)
                {
                    throw new ApplicationException("Invalid data!");
                }

                foreach (Match match in matches)
                {
                    double x = double.Parse(match.Groups[1].Value);
                    double y = double.Parse(match.Groups[2].Value);
                    double z = double.Parse(match.Groups[3].Value);

                    Point3D point = new Point3D(x, y, z);
                    path.AddPoint(point);
                }
            }

            return path;
        }
 public static double DistanceCalc(Point3D p1, Point3D p2)
 {
     double xDiff = p2.X - p1.X;
     double yDiff = p2.Y - p1.Y;
     double zDiff = p2.Z - p1.Z;
     double distance = Math.Sqrt(xDiff * xDiff + yDiff * yDiff + zDiff * zDiff);
     return distance;
 }
Exemplo n.º 4
0
 public static void Main()
 {
     Point3D p = new Point3D { X = 4, Y = 7, Z = 8 };
     Console.WriteLine(p.ToString());
     Console.WriteLine(StartingPoint);
 }
Exemplo n.º 5
0
 public void AddPoint(Point3D p)
 {
     this.path.Add(p);
 }