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(); }
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; }
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; }
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; }