Example #1
0
    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);
    }
Example #2
0
    public static void Main()
    {
        vector3d m = new vector3d(4, 5, 3);

        WriteLine($"test vector: {m}");
        WriteLine($"to String: {m.ToString()}");
        vector3d n = m * 2;

        WriteLine($"multiplication by 2, {n}");
        double a = n.dot_product(m);

        WriteLine($"dot_product, {a}");
    }
Example #3
0
    public static int Main()
    {
        var v = new vector3d(1, 2, 3);
        var u = new vector3d(3, 4, 5);

        WriteLine($"{v} + {u} = {v+u}");
        WriteLine($"{v} - {u} = {v-u}");
        WriteLine($"{v} * {2} = {v*2}");
        WriteLine($"{2} * {v} = {2*v}");
        WriteLine($"{v} dot {u} = {v.dot_product(u)}");
        WriteLine($"{v} cross {u} = {v.cross_product(u)}");
        WriteLine($"The magnitude of the vector {v} is {vector3d.magnitude(v)}");
        WriteLine($"{v} / {2} = {v/2}");
        v.x = 9;
        WriteLine(v);
        return(0);
    }
Example #4
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);
    }
Example #5
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);
    }
Example #6
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);
    }
Example #7
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);
    }