Ejemplo n.º 1
0
        public static TVector3D operator -(TVector3D a, TVector3D b)
        {
            double    n   = a.x - b.x;
            double    m   = a.y - b.y;
            double    k   = a.z - b.z;
            TVector3D vec = new TVector3D(n, m, k);

            return(vec);
        }
Ejemplo n.º 2
0
 public void VecEquals(TVector3D vec)
 {
     if (x == vec.x && y == vec.y && z == vec.z)
     {
         Console.WriteLine("Vec1 equals Vec2");
     }
     else
     {
         Console.WriteLine("Vec1 not equals to vec2");
     }
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            TVector2D vec1 = new TVector2D();

            vec1.EnterVec();
            vec1.ShowVec();
            TVector2D vec2 = new TVector2D(22, 3);

            vec2.ShowVec();

            TVector2D vec3 = new TVector2D(vec1);

            vec3.ShowVec();
            Console.WriteLine(vec1.VecLength());
            vec1.VecNormal();
            vec1.VecEquals(vec2);

            Console.WriteLine(vec1 + vec2);
            Console.WriteLine(vec1 - vec2);
            Console.WriteLine(vec1 * vec2);
            //2)

            HashSet <TVector2D> hash = new HashSet <TVector2D>();

            hash.Add(vec1);

            if (hash.Contains(vec1))
            {
                Console.WriteLine("vector was found!");
            }
            else
            {
                Console.WriteLine("vector not found!");
            }
            TVector2DF           vec4  = new TVector2DF(2, 3);
            HashSet <TVector2DF> hash2 = new HashSet <TVector2DF>();
            TVector2DF           vec5  = new TVector2DF(2, 3);

            hash2.Add(vec4);
            Console.WriteLine(vec4.GetHashCode());
            Console.WriteLine(vec5.GetHashCode());

            if (vec5.Equals(hash2))
            {
                Console.WriteLine("vector was found!");
            }
            else
            {
                Console.WriteLine("vector not found!");
            }
            HashSet <TVector3D> hash3 = new HashSet <TVector3D>();
            TVector3D           vec6  = new TVector3D(2, 3, 4);
            TVector3D           vec7  = new TVector3D(2, 3, 5);
            TVector3D           vec8  = new TVector3D(2, 3, 2);
            TVector3D           vec9  = new TVector3D(2, 3, 7);
            TVector3D           vec10 = new TVector3D(2, 3, 6);

            hash3.Add(vec6);
            hash3.Add(vec7);
            hash3.Add(vec8);
            hash3.Add(vec9);
            hash3.Add(vec10);
            Console.WriteLine(hash3.Count);

            HashSet <TVector3DF> hash4 = new HashSet <TVector3DF>();
            TVector3DF           vec11 = new TVector3DF(2, 3, 4);
            TVector3DF           vec12 = new TVector3DF(2, 3, 5);
            TVector3DF           vec13 = new TVector3DF(2, 3, 2);
            TVector3DF           vec14 = new TVector3DF(2, 3, 7);
            TVector3DF           vec15 = new TVector3DF(2, 3, 6);

            hash4.Add(vec11);
            hash4.Add(vec12);
            hash4.Add(vec13);
            hash4.Add(vec14);
            hash4.Add(vec15);
            Console.WriteLine(hash4.Count);
        }
Ejemplo n.º 4
0
 public TVector3DF(TVector3D vec)
 {
     this.x = vec.x;
     this.y = vec.y;
     this.z = vec.z;
 }