static void Main()
        {
            var firstPoint = new Point3D(1, 2, 3);
            var secondPoint = new Point3D(4, 5, 6);

            Console.WriteLine($"{DistanceCalculator.CalcDistance(firstPoint, secondPoint)}");
        }
예제 #2
0
 static void Main(string[] args)
 {
     Point3D pointA = new Point3D(4, 4, 5);
     Point3D pointB = new Point3D(6, 7, 8);
     double testDistance = DistanceCalculator.CalculateDistance(pointA,pointB);
     Console.WriteLine("{0:F13}",testDistance);
 }
        static void Main(string[] args)
        {
            Point3D p1 = new Point3D(2,3,4);
            Point3D p2 = new Point3D(4,-1,2);

            Console.WriteLine(DistanceCalculator.CalculateDistance(p1, p2));
        }
        public static Path3D LoadPathFromFile(string filepath)
        {
            Path3D path = new Path3D();

            using (StreamReader reader = new StreamReader(filepath))
            {
                string line = reader.ReadLine();
                const string PointPattern = @"[xyz=:\-\s](\d+(?:(?:\.|,)\d+)*)";

                while (line != null)
                {
                    MatchCollection matches = Regex.Matches(line, PointPattern);
                    if (matches.Count == 3)
                    {
                        double x = double.Parse(matches[0].Groups[1].Value);
                        double y = double.Parse(matches[1].Groups[1].Value);
                        double z = double.Parse(matches[2].Groups[1].Value);

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

                    line = reader.ReadLine();
                }
            }
            return path;
        }
예제 #5
0
        static void Main(string[] args)
        {
            Point3D point1 = new Point3D(-10.3, -6.5, 8.6);
            Point3D point2 = new Point3D(16, 6.6, 2.5);

            Console.WriteLine(DistanceCalculator.CalculateDistance(point1, point2));
        }
예제 #6
0
        public static double Distance(Point3D PointA, Point3D PointB)
        {
            double distance = 0;
            distance = Math.Sqrt(Math.Pow(PointA.X - PointB.X, 2) + Math.Pow(PointA.Y - PointB.Y, 2) + Math.Pow(PointA.Z - PointB.Z, 2));

            return distance;
        }
예제 #7
0
 static void Main(string[] args)
 {
     Point3D newPoint = new Point3D(34, 23, 1);
     Console.WriteLine("{0}  {1}  {2}", newPoint.PointX, newPoint.PointY, newPoint.PointZ);
     Console.WriteLine(Point3D.StartingPoint);
     Console.WriteLine(newPoint);
 }
예제 #8
0
 private void AddPoints(Point3D[] points)
 {
     foreach (var point in points)
     {
         this.Path.Add(point);
     }
 }
예제 #9
0
        static void Main()
        {
            Point3D point = new Point3D(12.3, 14.5, 1.4);
            Console.WriteLine(point);

            Console.WriteLine(Point3D.StartPoint);
        }
        static void Main()
        {
            var firstPoint = new Point3D(1, 2, 3);
            var secondPoint = new Point3D(4, 5, 6);

            Console.WriteLine("First Point: " + firstPoint);
            Console.WriteLine("Second Point: " + secondPoint);
            Console.WriteLine("Starting Point: " + Point3D.StartingPoint);
        }
예제 #11
0
        static void Main(string[] args)
        {
            Point3D p = new Point3D(2,3,6);
            Console.WriteLine(p);

            Point3D p2 = new Point3D(-1,2.3,24);
            Console.WriteLine(p2);

            Console.WriteLine(Point3D.StartingPoint);
        }
예제 #12
0
파일: Program.cs 프로젝트: stoyans/Telerik
        static void Main()
        {
            Point3D point = new Point3D(2, 3, 7);
            Point3D point2 = new Point3D(1, -3, 8);
            Console.WriteLine(point.ToString());
            Console.WriteLine(CalculateDistance.Distance(point, point2));

            Path pathOfPoints3D = new Path();
            pathOfPoints3D.AddPoint(point);
            pathOfPoints3D.AddPoint(point2);
            PathStorage.SavePaths(pathOfPoints3D);
            PathStorage.LoadPaths();
        }
        static void Main(string[] args)
        {
            try
            {
                Point3D point1 = new Point3D(1, 2, 3);
                Point3D point2 = new Point3D(-3, 4, 0);
                Path3D path = new Path3D(point1, point2);

                Storage.SavePathToFile("../../path.txt", path.ToString());
                Console.WriteLine("Load from file:\n" + Storage.LoadPathFromFile("../../path.txt"));
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #14
0
        public static void LoadPaths()
        {
            StreamReader readfromFile = new StreamReader("../../3DPoints.txt");
            string line = string.Empty;
            Point3D loadPoint = new Point3D();

            using (readfromFile)
            {
                while ((line = readfromFile.ReadLine()) != null)
                {
                    string[] valuesOnLine = line.Split(' ');

                    loadPoint = new Point3D(int.Parse(valuesOnLine[0]), int.Parse(valuesOnLine[1]), int.Parse(valuesOnLine[2]));
                    Console.WriteLine(loadPoint.ToString());
                }
            }
        }
예제 #15
0
파일: Path.cs 프로젝트: stoyans/Telerik
 public void AddPoint(Point3D point)
 {
     pathOfPoints.Add(point);
 }
예제 #16
0
파일: Point3D.cs 프로젝트: stoyans/Telerik
 static Point3D()
 {
     pointO = new Point3D(0, 0, 0);
 }
예제 #17
0
 static void Main(string[] args)
 {
     Point3D point = new Point3D(5, 6, 7);
     Console.WriteLine(point.ToString());
 }
예제 #18
0
        static Point3D()
        {

            startPoint = new Point3D(0, 0, 0);
            Console.WriteLine("Center {0}", startPoint);
        }
 public static double CalculateDistance(Point3D point1, Point3D point2)
 {
     return
         Math.Sqrt(Math.Pow(point2.X - point1.X, 2) + Math.Pow(point2.Y - point1.Y, 2) +
                   Math.Pow(point2.Z - point1.Z,2));
 }