Esempio n. 1
0
        static void Main(string[] args)
        {
            Vector vec1 = new Vector(5);
            Vector vec2 = new Vector(vec1);
            Vector vec3 = new Vector(new double[] { 1.2, 5.5, 4.7, 8, 6.4 });
            Vector vec4 = new Vector(5, new double[] { 1, 2, 5, 4, 5 });

            Vector sumTest1 = new Vector(7, new double[] { 1, 2, 3, 4, 5 });
            Vector sumTest2 = new Vector(5, new double[] { 1, 2, 3, 4, 5 });

            Vector vec5 = new Vector(5, new double[] { 1, 2, 5, 4, 5, 6, 7 });
            Vector vec6 = new Vector(7, new double[] { 1, 2, 5, 4, 5 });

            Vector vec7  = new Vector(7, new double[] { 1, 2, 5, 4, 5 });
            Vector vec8  = new Vector(5, new double[] { 1, 2, 3, 4, 5 });
            Vector vec9  = new Vector(7, new double[] { 4, 0, 6, 4, 5 });
            Vector vec10 = new Vector(5, new double[] { 3, 2, 3, 4, 5 });
            Vector vec11 = new Vector(7, new double[] { 1, 2, 3, 4, 5 });
            Vector vec12 = new Vector(5, new double[] { 6, 6, 6, 1, 5 });
            Vector vec13 = new Vector(15, new double[] { 9, 8, 0, 0, 5 });


            sumTest1.Sum(sumTest2);
            vec6.Difference(vec7);
            vec8.Multiplication(10);

            int    size      = vec13.GetSize();
            bool   equals    = vec4.Equals(vec5);
            double component = vec3.GetComponent(3);

            vec3.SetComponent(0, 100);

            vec12.Turn();
            double length = vec11.GetLength();

            Vector vector1 = Vector.Sum(vec5, vec7);
            Vector vector2 = Vector.Difference(vec5, vec4);
            double vector3 = Vector.ScalarMultiplication(vec4, vec5);

            vec4.SetComponent(0, 5);
            double vector4 = Vector.ScalarMultiplication(vec5, vec4);
            bool   equals1 = vector3.Equals(vector4);

            Vector[] vectors = new Vector[] { vec1, vec2, vec3, vec4, vec5, vec6, vec7, vec8, vec9, vec10, vec11, vec12, vec13 };

            foreach (Vector value in vectors)
            {
                Console.WriteLine(value + " " + value.GetSize());
            }
            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var vector1 = new Vector(1, new double[] { 1, 2, 4 });

            Console.WriteLine("Вектор1: " + vector1.ToString());

            var vector2 = new Vector(2, new double[] { 1, 2, 4 });

            Console.WriteLine("Вектор2: " + vector2.ToString());

            var vector3 = new Vector(3, new double[] { 1, 2, 4 });

            Console.WriteLine("Вектор3: " + vector3.ToString());

            var vector4 = new Vector(2, new double[] { 1, 1 });

            Console.WriteLine("Вектор4: " + vector4.ToString());

            var vector5 = new Vector(2, new double[] { 2, 2 });

            Console.WriteLine("Вектор5: " + vector5.ToString());
            Console.WriteLine();

            var vector6 = new Vector(2, new double[] { -2, -2 });

            Console.WriteLine("Вектор6: " + vector6.ToString());
            Console.WriteLine();

            vector1.AddVector(vector2);
            Console.WriteLine("Сложение вектора 1 и 2 нестатическим методом: " + vector1.ToString());

            Console.WriteLine("Сложение вектора 2 и 3 статическим методом: " + Vector.GetVectorsSum(vector2, vector3).ToString());

            vector4.SubtractVector(vector5);
            Console.WriteLine("Разность векторов 5 и 4 нестатическим методом: " + vector4.ToString());

            Console.WriteLine("Разность векторов 5 и 4 статическим методом: " + Vector.GetVectorsDifference(vector5, vector4).ToString());
            Console.WriteLine();

            Console.WriteLine("Вектор1 до скалярного умножения: " + vector1.ToString());
            vector1.MultiplyScalar(2);
            Console.WriteLine("Скалярное умножение вектора1 нестатическим методом на 2: " + vector1.ToString());
            Console.WriteLine();

            Console.WriteLine("Умножение вектора1 на вектор2: " + Vector.GetScalarMultiplication(vector1, vector2));
            Console.WriteLine();

            Console.WriteLine("Вектор5 до разворота: " + vector5.ToString());
            vector5.Invert();
            Console.WriteLine("Вектор5 после разворота: " + vector5.ToString());
            Console.WriteLine();

            Console.WriteLine("Длинна вектора4: " + vector4.GetLenght());
            Console.WriteLine();

            Console.WriteLine("Вторая компанента в векторе 3 равна: " + vector3.GetComponent(1));
            Console.WriteLine("Меняем эту компаненту на 6: ");
            vector3.SetComponent(6, 1);
            Console.WriteLine("Теперь компанента равна: " + vector3.GetComponent(1));
            Console.WriteLine();

            Console.WriteLine($"Вектор5 {vector5} {(vector5.Equals(vector6) ? "равен" : "не равен" )} вектору6 {vector6}");
            Console.WriteLine($"Вектор5 {vector5} {(vector5.Equals(vector3) ? "равен" : "не равен")} вектору3 {vector3}");
        }