// method that calculates the distance between two 3D points
 public static double CalcDistance(Struct3DPoint point1, Struct3DPoint point2)
 {
     double distance = Math.Sqrt((point1.X - point2.X)*(point1.X - point2.X) +
                                 (point1.Y - point2.Y)*(point1.Y - point2.Y) +
                                 (point1.Z - point2.Z)*(point1.Z - point2.Z));
     return distance;
 }
Example #2
0
    // method that loads/saves the path from a file
    public static Path LoadPath(string fileName)
    {
        Path points = new Path();

        using (StreamReader reader = new StreamReader(fileName))
        {
            string line = reader.ReadLine();

            while (line != null)
            {
                string[] linePoints = line.Split(' ');
                Struct3DPoint currentPoint = new Struct3DPoint();

                currentPoint.X = int.Parse(linePoints[0]);
                currentPoint.Y = int.Parse(linePoints[1]);
                currentPoint.Z = int.Parse(linePoints[2]);

                points.Add(currentPoint);

                line = reader.ReadLine();
            }
        }
        return points;
    }
Example #3
0
 // method that adds points to the list of points
 public void Add(Struct3DPoint currentPoint)
 {
     this.points.Add(currentPoint);
 }