Exemplo n.º 1
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}");
    }
Exemplo n.º 2
0
    static int Main()
    {
        vector3d a             = new vector3d(1, 1, 0);
        vector3d b             = new vector3d(0, 0, 1);
        string   str_a         = a.ToString();
        string   str_b         = b.ToString();
        string   str_b_minus_a = (b - a).ToString();
        string   str_a_dot_b   = (vector3d.dot_product(a, b)).ToString();
        string   str_a_X_b     = (vector3d.vector_product(a, b)).ToString();
        string   str_mag_a     = (vector3d.magnitude(a)).ToString();

        Write("a = " + str_a + "\n");
        Write("b = " + str_b + "\n");
        Write("b-a = " + str_b_minus_a + "\n");
        Write("a dot b = " + str_a_dot_b + "\n");
        Write("a X b = " + str_a_X_b + "\n");
        Write("magnitude(a) = " + str_mag_a + "\n");
        return(0);
    }
Exemplo n.º 3
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);
    }
Exemplo n.º 4
0
    public static void Main()
    {
        vector3d a = new vector3d(1, 2, 3);
        vector3d b = new vector3d(4, 5, 6);

        WriteLine("The vectors are: " + a.ToString() + " and " + b.ToString());
        vector3d c = a + b;

        WriteLine("Their sum is: " + c.ToString());
        vector3d d = a - b;

        WriteLine("Their difference is: " + d.ToString());
        double e = dotProduct(a, b);

        WriteLine("Their dot is: " + e.ToString());
        vector3d f = vectorProduct(a, b);

        WriteLine("Their cross is: " + f.ToString());
        double g = magnitude(a);
        double h = magnitude(b);

        WriteLine("Their magnitudes are: " + g.ToString() + " and " + h.ToString());
    }