示例#1
0
        static void Main(string[] args)
        {
            Vector a = new Vector(0, 0, 1);
            Vector b = new Vector(1, 0, 0);

            Vector Add = Vector.Addition(a, b);
            a.Output();
            Console.Write(" + ");
            b.Output();
            Console.Write(" = ");
            Add.Output();

            Console.WriteLine("\nScalar product: ");
            a.Output();
            Console.Write(" * ");
            b.Output();
            Console.Write(" = ");
            Console.Write(Vector.ScalarProduct(a, b));

            Console.WriteLine("\nVector product: ");
            a.Output();
            Console.Write(" * ");
            b.Output();
            Console.Write(" = ");
            Vector res = Vector.VectorProduct(a, b);
            res.Output();

            Console.ReadKey();
        }
示例#2
0
 public static Vector VectorProduct(Vector a, Vector b)
 {
     Vector res = new Vector();
     res.x = a.y * b.z - a.z * b.y;
     res.y = a.x * b.z - a.z * b.x;
     res.z = a.x * b.y - a.y * b.x;
     return res;
 }
示例#3
0
 public static Vector Addition(Vector a, Vector b)
 {
     Vector res = new Vector();
     res.x = a.x + b.x;
     res.y = a.y + b.y;
     res.z = a.z + b.z;
     return res;
 }
示例#4
0
 public static int ScalarProduct(Vector a, Vector b)
 {
     int res;
     res = a.x * b.x + a.y * b.y + a.z * b.z;
     return res;
 }