Esempio n. 1
0
        public Vector2Int(VectorInt vector)
        {
            if (vector.Length != 2)
            {
                throw new ArgumentException("Length of inner vector is not equal 2");
            }

            _innerVector = vector;
            X            = vector.GetValue(0);
            Y            = vector.GetValue(1);
        }
Esempio n. 2
0
        public static Vector Div(VectorInt vector1, float number)
        {
            var length = vector1._values.Length;

            var newVectorValues = new float[length];

            for (var i = 0; i < length; ++i)
            {
                newVectorValues[i] = vector1.GetValue(i) / number;
            }

            return(new Vector(newVectorValues));
        }
Esempio n. 3
0
        public static VectorInt Add(VectorInt vector1, VectorInt vector2)
        {
            var length = vector1._values.Length;

            if (length != vector2.Length)
            {
                throw new ArgumentException("Vectors must have equal length");
            }

            var newVectorValues = new int[length];

            for (var i = 0; i < length; ++i)
            {
                newVectorValues[i] = vector1.GetValue(i) + vector2.GetValue(i);
            }

            return(new VectorInt(newVectorValues));
        }