Ejemplo n.º 1
0
        public static double CalculateDistanceBetweenPoints(Point3D a, Point3D b)
        {
            long deltaX = Math.Abs(a.X - b.X);
            long deltaY = Math.Abs(a.Y - b.Y);
            long deltaZ = Math.Abs(a.Z - b.Z);

            return Math.Sqrt((
                Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2) + Math.Pow(deltaZ, 2)));
        }
        public void CalculateDistanceBetweenPointsTest()
        {
            Point3D a = new Point3D(1, 2, 3);
            Point3D b = new Point3D(4, 5, 6);

            double expected = Math.Sqrt(27);
            double actual = PointOperations.CalculateDistanceBetweenPoints(a, b);

            Assert.AreEqual(expected, actual);
        }