public static List<Point3D> PointReader(string path)
        {
            Regex regex = new Regex(@"(\d+),\s?(\d+),\s?(\d+)");
            List<Point3D> points = new List<Point3D>();

            string file = File.ReadAllText(path);
            foreach (Match match in regex.Matches(file))
            {
                double X;
                double Y;
                double Z;

                try
                {
                    X = double.Parse(match.Groups[1].Value);
                    Y = double.Parse(match.Groups[2].Value);
                    Z = double.Parse(match.Groups[3].Value);

                    Point3D point = new Point3D(X, Y, Z);
                    points.Add(point);
                }
                catch (Exception)
                {
                    throw new FormatException("Not a 3D point.");
                }
            }
            return points;
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter X1 value:");
            string readX1 = Console.ReadLine();
            Console.WriteLine("Enter Y1 value:");
            string readY1 = Console.ReadLine();
            Console.WriteLine("Enter Z1 value:");
            string readZ1 = Console.ReadLine();

            Console.WriteLine("Enter X2 value:");
            string readX2 = Console.ReadLine();
            Console.WriteLine("Enter Y2 value:");
            string readY2 = Console.ReadLine();
            Console.WriteLine("Enter Z2 value:");
            string readZ2 = Console.ReadLine();

            double x1 = Test1.convertToDouble(readX1);
            double y1 = Test1.convertToDouble(readY1);
            double z1 = Test1.convertToDouble(readZ1);

            double x2 = Test1.convertToDouble(readX2);
            double y2 = Test1.convertToDouble(readY2);
            double z2 = Test1.convertToDouble(readZ2);

            Point3D p1 = new Point3D(x1, y1, z1);
            Point3D p2 = new Point3D(x2, y2, z2);

        }
 public static double CalculateDistanseMethod(Point3D firstPoint, Point3D secondPoint)
 {
     double distance = Math.Sqrt(((firstPoint.X - secondPoint.X)*(firstPoint.X - secondPoint.X)) +
                                 ((firstPoint.Y - secondPoint.Y)*(firstPoint.Y - secondPoint.Y)) +
                                 ((firstPoint.Z - firstPoint.Z)*(firstPoint.Z - firstPoint.Z)));
     return distance;
 }
Beispiel #4
0
 public static double CalcDistance(Point3D p1, Point3D p2){
     double distance = 0;
     distance = Math.Sqrt((p1.X - p2.X) * (p1.X - p2.X) +
         (p1.Y - p2.Y) * (p1.Y - p2.Y) +
         (p1.Z - p2.Z) * (p1.Z - p2.Z));
     return distance;
 }
        static void Main()
        {
            Point3D firstPoint = new Point3D(0, 0, 0);
            Point3D secondPoint = new Point3D(1, 2, 3);

            Console.WriteLine("First point coordinates: ");
            Console.WriteLine(firstPoint);
            Console.WriteLine("Second point coordinates: ");
            Console.WriteLine(secondPoint);
            Console.WriteLine("---------------------");
            Console.WriteLine("Distance between the two points: ");
            double distance = CalculateDistance.CalculateDistanseMethod(firstPoint, secondPoint);
            Console.WriteLine(distance);
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter X value:");
            string readX = Console.ReadLine();
            Console.WriteLine("Enter Y value:");
            string readY = Console.ReadLine();
            Console.WriteLine("Enter Z value:");
            string readZ = Console.ReadLine();

            double x = convertToDouble(readX);
            double y = convertToDouble(readY);
            double z = convertToDouble(readZ);

            //Point3D p1 = new Point3D(1.2, 3.3, 1);
            Point3D point = new Point3D(x, y, z);
            Console.WriteLine(point.ToString());

        }
Beispiel #7
0
 static Point3D()
 {
     Point3D.startingPoint = new Point3D(0, 0, 0);
 }
 static void Main()
 {
     Point3D point1 = new Point3D(12, 45, 20);
     Console.WriteLine(point1);
 }