public static double CalculateDistance(Point3D a, Point3D b)
 {
     double distance = 0;
     double tempCalc = Math.Pow((b.X - a.X), 2) + Math.Pow((b.Y - a.Y), 2) + Math.Pow((b.Z - a.Z), 2);
     distance = Math.Sqrt(tempCalc);
     return distance;
 }
Ejemplo n.º 2
0
        public static Path3D LoadPaths()
        {
            StreamReader reader = new StreamReader(@"../../points.txt");
            List<Point3D> points = new List<Point3D>();

            using (reader)
            {
                while (true)
                {
                    string line = reader.ReadLine();
                    if (string.IsNullOrEmpty(line))
                    {
                        break;
                    }
                    string[] args = line.Trim().Split('/');

                    string[] pointA = args[0].Split(new char[] {' '});
                    double Ax = double.Parse(pointA[0]);
                    double Ay = double.Parse(pointA[1]);
                    double Az = double.Parse(pointA[2]);

                    string[] pointB = args[1].Split(new char[] {' '});
                    double Bx = double.Parse(pointB[0]);
                    double By = double.Parse(pointB[1]);
                    double Bz = double.Parse(pointB[2]);

                    a = new Point3D(Ax, Ay, Az);
                    b = new Point3D(Bx, By, Bz);

                    points.Add(a);
                    points.Add(b);
                }
            }
            return new Path3D(points.ToArray());
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Calculates distance between two points in 3D space using <see cref="Point3D"/> type coordinates.
 /// </summary>
 /// <param name="pointA">Point A coordinates.</param>
 /// <param name="pointB">Point B coordinates</param>
 /// <returns></returns>
 public static double Distance(Point3D pointA, Point3D pointB)
 {
     double axisXDistance = pointA.X - pointB.X;
     double axisYDistance = pointA.Y - pointB.Y;
     double axisZDistance = pointA.Z - pointB.Z;
     return Math.Sqrt((axisXDistance * axisXDistance) + (axisYDistance * axisYDistance) + (axisZDistance * axisZDistance));
 }
        public static double CalculateDistance3DPoint(Point3D firstPoint, Point3D secondPoint) 
        {
            float x = firstPoint.X - secondPoint.X;
            float y = firstPoint.Y - secondPoint.Y;
            float z = firstPoint.Z - secondPoint.Z;

            double calcDis = Math.Sqrt(Math.Pow(x, 2) + Math.Pow(y, 2) + Math.Pow(z, 2));

            return calcDis;
        } 
Ejemplo n.º 5
0
        public static double CalculateDistance3D(Point3D pointA, Point3D pointB)
        {
            double deltaX = pointA.XCoordinate - pointB.XCoordinate;
            double deltaY = pointA.YCoordinate - pointB.YCoordinate;
            double deltaZ = pointA.ZCoordinate - pointB.ZCoordinate;

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

            return distance;
        }
Ejemplo n.º 6
0
 public static void AddToList(Point3D point)
 {
     sequence.Add(point);
 }