Ejemplo n.º 1
0
        private static void Main()
        {
            // stuff to demonstrate arithmetic operations
            Vector vect1 = new Vector(1.0, 1.5, 2.0);
            Vector vect2 = new Vector(0.0, 0.0, -10.0);

            Vector vect3 = vect1 + vect2;

            Console.WriteLine("vect1 = " + vect1);
            Console.WriteLine("vect2 = " + vect2);
            Console.WriteLine("vect3 = vect1 + vect2 = " + vect3);
            Console.WriteLine("2*vect3 = " + 2 * vect3);

            vect3 += vect2;

            Console.WriteLine("vect3+=vect2 gives " + vect3);

            vect3 = vect1 * 2;

            Console.WriteLine("Setting vect3=vect1*2 gives " + vect3);

            double dot = vect1*vect3;

            Console.WriteLine("vect1*vect3 = " + dot);

            Console.ReadLine();
        }
Ejemplo n.º 2
0
 public static Vector operator +(Vector lhs, Vector rhs)
 {
     Vector result = new Vector(lhs);
      result.x += rhs.x;
      result.y += rhs.y;
      result.z += rhs.z;
      return result;
 }
Ejemplo n.º 3
0
        private static void Main()
        {
            Vector vect1 = new Vector(3.0, 3.0, 1.0);
            Vector vect2 = new Vector(2.0, -4.0, -4.0);
            Vector vect3 = vect1 - vect2;
            Console.WriteLine("vect1 = " + vect1.ToString());
            Console.WriteLine("vect2 = " + vect2.ToString());
            Console.WriteLine("vect3 = " + vect3.ToString());

            Console.ReadLine();
        }
Ejemplo n.º 4
0
 static void Main()
 {
     // stuff to demonstrate arithmetic operations
      Vector vect1, vect2, vect3;
      vect1 = new Vector(3.0, 3.0, -10.0);
      vect2 = new Vector(3.0, 3.0, -10.0);
      vect3 = new Vector(2.0, 3.0, 6.0);
      Console.WriteLine("vect1==vect2 returns  " + (vect1==vect2));
      Console.WriteLine("vect1==vect3 returns  " + (vect1==vect3));
      Console.WriteLine("vect2==vect3 returns  " + (vect2==vect3));
      Console.WriteLine();
      Console.WriteLine("vect1!=vect2 returns  " + (vect1!=vect2));
      Console.WriteLine("vect1!=vect3 returns  " + (vect1!=vect3));
      Console.WriteLine("vect2!=vect3 returns  " + (vect2!=vect3));
 }
Ejemplo n.º 5
0
 public Vector(Vector rhs)
 {
     x = rhs.x;
      y = rhs.y;
      z = rhs.z;
 }