Esempio n. 1
0
        private static double DistMATH3(Datum3 p1, Datum3 p2)
        {
            double EQDist = Math.Sqrt(Math.Pow((p1.x3 - p2.x3), 2) + Math.Pow((p1.y3 - p2.y3), 2) + Math.Pow((p1.z3 - p2.z3), 2));

            //Console.WriteLine(p1.x + " " + p2.x + " , " + p1.y + " " + p2.y);
            return(EQDist);
        }
Esempio n. 2
0
        //private static void CalcDist3()
        //{
        //    double DatumPointDistance3 = 0;
        //    Datum3 RandomPoint3 = new Datum3();
        //    RandomPoint3.x3 = 0;
        //    RandomPoint3.y3 = 0;
        //    RandomPoint3.z3 = 0;
        //    Datum3[] D3 = new Datum3[1000];
        //    D3[999] = RandomPoint3;
        //    Random randomVector3 = new Random();
        //}

        private static void CalcDist3()
        {
            double DatumPointDistance3 = 0;
            Datum3 RandomPoint3        = new Datum3();

            RandomPoint3.x3 = 0;
            RandomPoint3.y3 = 0;
            RandomPoint3.z3 = 0;
            int index;

            Datum3[] D3 = new Datum3[1000];
            //D3[999] = RandomPoint3;
            Random randomVector3 = new Random();

            for (index = 0; index - 1 < 999; index++)
            {
                RandomPoint3.x3 = randomVector3.Next(1, 1001);
                RandomPoint3.y3 = randomVector3.Next(1, 1001);
                RandomPoint3.z3 = randomVector3.Next(1, 1001);
                D3[index]       = RandomPoint3;
            }
            //this was a math testDatumPointDistance3 = DistMATH3(D3[RandomPoint3.x3], D3[RandomPoint3.y3]);
            //this was a math test Console.WriteLine(DatumPointDistance3);
            double allItem3      = 0;
            int    BigIteration  = 1;
            int    EVCheck       = 0;
            int    ICheck        = 0;
            double ShortestDist3 = double.MaxValue;

            foreach (Datum3 Iteration3 in D3)
            {
                foreach (Datum3 everything3 in D3)
                {
                    if (EVCheck > 999)
                    {
                        EVCheck = 0;
                    }
                    //Console.WriteLine($"Test ICHECK: {ICheck} Test EVCheck: {EVCheck}");
                    if (EVCheck != ICheck)
                    {
                        allItem3 = DistMATH3(everything3, Iteration3);
                        //Console.WriteLine($"This is the equated Distance: {allItem2} This is how many times: {BigIteration}");
                        BigIteration += 1;
                        if (allItem3 < ShortestDist3)
                        {
                            ShortestDist3 = allItem3;
                            Console.WriteLine($"Point {EVCheck} ({everything3.x3},{everything3.y3},{everything3.z3}) , Point {ICheck} ({Iteration3.x3},{Iteration3.y3},{Iteration3.z3})");
                            Console.WriteLine($"have the Shortest Distance of {ShortestDist3}");
                        }
                    }
                    EVCheck++;
                }
                ICheck++;
            }
            //Console.WriteLine(everything2 + " Look HERE " + Iteration);
            //Console.WriteLine($"This is the big Iteration {BigIteration}");
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("This is the Vector Distance Exercise");
            bool again = true;

            while (again)
            {
                Console.Write("\nEnter 2 to calculate 2 element vector," +
                              "3 to calculate 3 element vector, or 9 to quit.");
                Console.WriteLine("Enter: ");
                int input = 0;
                try
                {
                    input = int.Parse(Console.ReadLine());
                }
                catch (Exception)
                {
                    Console.WriteLine("Input must be in the proper format.");
                }
                switch (input)
                {
                case 2:
                    Console.WriteLine("\nTwo element vector: ");
                    Datum2 d2 = new Datum2();
                    d2.CalcPairs();
                    break;

                case 3:
                    Console.WriteLine("\nThree element vector");
                    Datum3 d3 = new Datum3();
                    d3.CalcDist();
                    break;

                case 9:
                    Console.WriteLine("Exiting...");
                    again = false;
                    break;

                default:
                    Console.WriteLine("Input not recognized.");
                    break;
                }
            }
        }