public static int Main() { vector3d v = new vector3d(1, 2, 3); vector3d u = new vector3d(7, 5, 8); v.print("v= "); u.print("u= "); vector3d w = u + v; w.print("w= "); (v * 2).print("2*v= "); vector3d A = v.vector_product(u); A.print("v x u = "); double B = v.dot_product(u); System.Console.Write("v dot u ={0}\n", B); double C = v.magnitude(); System.Console.Write("|v| ={0}\n", C); return(0); }
public static void Main() { vector3d v = new vector3d(1, 1, 1); vector3d u = new vector3d(1, 2, 3); Write($"{v}*{u} = " + v * u + "\n"); Write($" {v} - {u} = " + (v - u) + "\n"); Write($"|{v}| = " + v.magnitude() + "\n"); }
static int Main() { vector3d v = new vector3d(1, 1, 2); vector3d u = new vector3d(0, 1, 0); Console.WriteLine($"Dot product of v = (1,1,2) and u = (0,1,0)"); Console.WriteLine($"v*u = {vector3d.dotproduct(u,v)}"); Console.WriteLine("Vector product:"); Console.WriteLine($"v x u = {vector3d.vectorproduct(v,u)}"); Console.WriteLine("Magnitude of v:"); Console.WriteLine($"|v| = {v.magnitude()}"); return(0); }
static int Main() { vector3d v = new vector3d(1, 2, 3); vector3d u = new vector3d(4, 5, 6); double c = 1.5; WriteLine($"v = {v}"); WriteLine($"u = {u}"); WriteLine($"c = {c}"); WriteLine($"c*v = {c*v} & v*c = {v*c} "); WriteLine($"v+u = {v+u}"); WriteLine($"v-u = {v-u}"); WriteLine($"v*u = {v.dot_product(u)}"); WriteLine($"vxu = {v.vector_product(u)}"); WriteLine($"||v|| = {v.magnitude()}"); return(0); }
static int Main() { vector3d v1 = new vector3d(1, 2, 3); vector3d v2 = new vector3d(2, 2, 1); Write("v1 = "); v1.ToString(); Write("v2 = "); v2.ToString(); Write("v1.magnitude() = {0}\n", v1.magnitude()); vector3d v3 = v1 * 2; Write("v1*2 = "); v3.ToString(); Write("2*v1 = "); (2 * v1).ToString(); Write("v1+v2 = "); (v1 + v2).ToString(); Write("v1-v2 = "); (v1 - v2).ToString(); Write("v1.dot_product(v2) = {0}\n", v1.dot_product(v2)); Write("v1.vector_product(v2) = "); v1.vector_product(v2).ToString(); WriteLine($" v1.x={v1.x}, v1.y={v1.y}, v1.z={v1.z}"); return(0); }
static int Main() { vector3d v = new vector3d(1, 2, 3); vector3d u = new vector3d(5, 4, 3); v.print("v= "); u.print("u= "); (v + u).print("u+v= "); (v - u).print("u-v= "); (2 * v).print("2*v= "); System.Console.Write("v.x = {0}\n", v.x); v.x = 5.0; System.Console.Write("v.x = {0}\n", v.x); System.Console.Write("v@u= {0}\n", v.dot_product(u)); v.vector_product(u).print("v cross u= "); System.Console.Write("|v|= {0}\n", v.magnitude()); return(0); }
public static int Main() { vector3d v = new vector3d(2, 427, -17); vector3d u = new vector3d(351, -379, 1); double c = System.Math.PI; v.print("v="); u.print("u="); (v + u).print("v+u="); (v - u).print("v-u="); double vu = v.dot_product(u); Write($"v.u={vu}\n"); (v.vector_product(u)).print("v x u ="); Write("|v|={0}\n", v.magnitude()); (v * c).print($"v*{c}="); return(0); }
static int Main() { System.Console.Write("Example with vector v:\n"); vector3d v = new vector3d(1.2, 1.5, 2.0); System.Console.Write("v = " + v + "\n"); System.Console.Write("v_x = " + v.x + "\n"); System.Console.Write("Changing v_x to 10 and v_y to 3.\n"); v.x = 10; v.y = 3; System.Console.Write("v_x = " + v.x + "\n"); v.print("v="); System.Console.Write("Defining new vector u:"); vector3d u = new vector3d(2, 5, 7); double a = 2; u.print("u="); System.Console.Write("Calculating 2*u, u+v and cross-product of u and v \n"); vector3d w = u * a; w.print("2*u = "); vector3d q = u + v; q.print("u+v = "); vector3d t = v.vectorProduct(u); t.print("u x v = "); System.Console.Write("Magnitude v = {0:f3}\n", v.magnitude()); return(0); }