Ejemplo n.º 1
0
 // non-static methods
 public Vector VectorMultiply(Vector operand)
 {
     int x_temp = this.x, y_temp = this.y, z_temp = this.z;
     this.x = y_temp * operand.z - z_temp * operand.y;
     this.y = x_temp * operand.z - z_temp * operand.x;
     this.z = x_temp * operand.y - y_temp * operand.x;
     return this;
 }
Ejemplo n.º 2
0
 // static methods
 public static Vector VectorMultiply(Vector operand_1, Vector operand_2)
 {
     int x_res, y_res, z_res;
     x_res = operand_1.y * operand_2.z - operand_1.z * operand_2.y;
     y_res = operand_1.x * operand_2.z - operand_1.z * operand_2.x;
     z_res = operand_1.x * operand_2.y - operand_1.y * operand_2.x;
     return new Vector(x_res, y_res, z_res);
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //using static method

            Hello();

            // array
            int[] x = new int[5] /* optional */ {1, 2, 3, 4, 5};
            x[4] = 1;

            for (int i = 0; i < x.Length; ++i)
            {
                Console.WriteLine(x[i]);
            }

            // array of arrays

            int[][] matrix = new int[2][];

            for (int i = 0; i < matrix.Length; ++i)
            {
                matrix[i] = new int[i + 1];
            }

            matrix[1][0] = 1;

            // matrix

            int[,] matrix_2 = new int[2, 2];

            matrix_2[1, 1] = 7;

            // var (like auto in C++)

            var pi = Math.Atan(1) * 4;
            object z = pi;
            double q = (double)z;

            Console.WriteLine(q);

            // wait for user's input for exit

            Vector vector_test1 = new Vector(0, 0, 1), vector_test2 = new Vector(1, 0, 0);
            int scalar_value = Vector.ScalarMultiply(vector_test1, vector_test2);
            Vector vector_test3 = Vector.VectorMultiply(vector_test1, vector_test2);
            Console.WriteLine(scalar_value);
            vector_test3.Print();

            Console.ReadKey();
        }
Ejemplo n.º 4
0
 public int ScalarMultiply(Vector operand)
 {
     int result;
     result = this.x * operand.x + this.y * operand.y + this.z * operand.z;
     return result;
 }
Ejemplo n.º 5
0
 public static int ScalarMultiply(Vector operand_1, Vector operand_2)
 {
     int result;
     result = operand_1.x * operand_2.x + operand_1.y * operand_2.y + operand_1.z * operand_2.z;
     return result;
 }