public static Path3D LoadPath(string file)
        {
            StringReader reader = new StringReader(file);

            Path3D pointList = new Path3D();

            using (reader)
            {
                string line = reader.ReadLine();

                while (line != null)
                {
                    decimal[] pointCoords = line.Split(',').Select(decimal.Parse).ToArray();

                    decimal x = pointCoords[0];

                    decimal y = pointCoords[1];

                    decimal z = pointCoords[2];

                    Point3D point = new Point3D(x, y, z);

                    pointList.AddPoint(point);

                    line = reader.ReadLine();
                }

                return pointList;
            }
        }
        public static decimal CalculateDistance(Point3D firstPoint, Point3D secondPoint)
        {
            decimal result = new decimal();

            decimal xDistance = (firstPoint.X - secondPoint.X) * (firstPoint.X - secondPoint.X);
            decimal yDistance = (firstPoint.Y - secondPoint.Y) * (firstPoint.Y - secondPoint.Y);
            decimal zDistance = (firstPoint.Z - secondPoint.Z) * (firstPoint.Z - secondPoint.Z);

            result = (decimal)Math.Sqrt((double)(xDistance + yDistance + zDistance));

            return result;
        }
Esempio n. 3
0
 public void AddPoint(Point3D point)
 {
     this.listOfPoints.Add(point);
 }