Ejemplo n.º 1
0
        public static void ReadPointsCoord()
        {
            My3DPoint pointOne = new My3DPoint();
            My3DPoint pointTwo = new My3DPoint();

            Console.WriteLine("To calculate distance between two point in the 3D space,");
            Console.WriteLine("- enter first point cordinates x,y,z using space between them: ");
            string fiPointCoord = Console.ReadLine();

            string [] fiPointCoordArr = fiPointCoord.Split(' ');

            pointOne.X = double.Parse(fiPointCoordArr[0]);
            pointOne.Y = double.Parse(fiPointCoordArr[1]);
            pointOne.Z = double.Parse(fiPointCoordArr[2]);

            Console.WriteLine("- enter second point cordinates x,y,z using space between them: ");
            string secPointCoord = Console.ReadLine();

            string[] secPointCoordArr = secPointCoord.Split(' ');

            pointTwo.X = double.Parse(secPointCoordArr[0]);
            pointTwo.Y = double.Parse(secPointCoordArr[1]);
            pointTwo.Z = double.Parse(secPointCoordArr[2]);

            double finalDistance = 0;

            CalcDistance(pointOne, pointTwo, finalDistance);
        }
        public static void ReadPointsCoord()
        {
            My3DPoint pointOne = new My3DPoint();
            My3DPoint pointTwo = new My3DPoint();

            Console.WriteLine("To calculate distance between two point in the 3D space,");
            Console.WriteLine("- enter first point cordinates x,y,z using space between them: ");
            string fiPointCoord = Console.ReadLine();
            string [] fiPointCoordArr = fiPointCoord.Split(' ');

            pointOne.X = double.Parse(fiPointCoordArr[0]);
            pointOne.Y = double.Parse(fiPointCoordArr[1]);
            pointOne.Z = double.Parse(fiPointCoordArr[2]);

            Console.WriteLine("- enter second point cordinates x,y,z using space between them: ");
            string secPointCoord = Console.ReadLine();
            string[] secPointCoordArr = secPointCoord.Split(' ');

            pointTwo.X = double.Parse(secPointCoordArr[0]);
            pointTwo.Y = double.Parse(secPointCoordArr[1]);
            pointTwo.Z = double.Parse(secPointCoordArr[2]);

            double finalDistance = 0;

            CalcDistance(pointOne, pointTwo, finalDistance);
        }
Ejemplo n.º 3
0
        private static double CalcDistance(My3DPoint pointOne, My3DPoint pointTwo, double finalDistance)
        {
            finalDistance = Math.Sqrt(((pointTwo.X - pointOne.X) * (pointTwo.X - pointOne.X)) + ((pointTwo.Y - pointOne.Y) * (pointTwo.Y - pointOne.Y)) + ((pointTwo.Z - pointOne.Z) * (pointTwo.Z - pointOne.Z)));

            Console.WriteLine("The distance between your two points is: {0}", finalDistance);

            return(finalDistance);
        }
        private static double CalcDistance(My3DPoint pointOne, My3DPoint pointTwo, double finalDistance)
        {
            finalDistance = Math.Sqrt(((pointTwo.X - pointOne.X) * (pointTwo.X - pointOne.X)) + ((pointTwo.Y - pointOne.Y) * (pointTwo.Y - pointOne.Y)) + ((pointTwo.Z - pointOne.Z) * (pointTwo.Z - pointOne.Z)));

            Console.WriteLine("The distance between your two points is: {0}", finalDistance);

            return finalDistance;
        }
Ejemplo n.º 5
0
        public static int HoldPointSequence()
        {
            storedPoints = new List<My3DPoint>();
            My3DPoint currPoint = new My3DPoint();
            Console.WriteLine("Now enter each 3D point coordinates (x y z) using space between them: ");
            string pointCoord = string.Empty;

            for (int p = 0; p < pointsNumber; p++)
            {
                Console.WriteLine("point {0} coordinates: ", p);
                pointCoord = Console.ReadLine();
                string[] pointCoordArr = pointCoord.Split(' ');
                currPoint.X= int.Parse(pointCoordArr[0]);
                currPoint.Y = int.Parse(pointCoordArr[1]);
                currPoint.Z = int.Parse(pointCoordArr[2]);
                storedPoints.Add(currPoint);
            }
            return pointsNumber;
        }
Ejemplo n.º 6
0
 static void Main()
 {
     My3DPoint someTestPoint = new My3DPoint(1, 5, 7);
     Console.WriteLine("The coordinates x y z of the new 3D point are: {0}", someTestPoint.ToString());
 }
Ejemplo n.º 7
0
        static void Main()
        {
            My3DPoint someTestPoint = new My3DPoint(1, 5, 7);

            Console.WriteLine("The coordinates x y z of the new 3D point are: {0}", someTestPoint.ToString());
        }