diff --git a/Source/Engine/Core/Math/Int2.h b/Source/Engine/Core/Math/Int2.h index 682190fa8..47875a799 100644 --- a/Source/Engine/Core/Math/Int2.h +++ b/Source/Engine/Core/Math/Int2.h @@ -280,7 +280,82 @@ public: return Int2(a.X / b, a.Y / b); } - // Creates vector from minimum components of two vectors + /// + /// Gets a value indicting whether this vector is zero. + /// + /// True if the vector is zero, otherwise false. + bool IsZero() const + { + return X == 0 && Y == 0; + } + + /// + /// Gets a value indicting whether any vector component is zero. + /// + /// True if a component is zero, otherwise false. + bool IsAnyZero() const + { + return X == 0 || Y == 0; + } + + /// + /// Gets a value indicting whether this vector is one. + /// + /// True if the vector is one, otherwise false. + bool IsOne() const + { + return X == 1 && Y == 1; + } + + /// + /// Calculates a vector with values being opposite to values of that vector + /// + /// Negative vector + Int2 GetNegative() const + { + return Int2(-X, -Y); + } + + /// + /// Returns average arithmetic of all the components + /// + /// Average arithmetic of all the components + float AverageArithmetic() const + { + return (X + Y) * 0.5f; + } + + /// + /// Gets sum of all vector components values + /// + /// Sum of X, Y, Z and W + int32 SumValues() const + { + return X + Y; + } + + /// + /// Returns minimum value of all the components + /// + /// Minimum value + int32 MinValue() const + { + return Math::Min(X, Y); + } + + /// + /// Returns maximum value of all the components + /// + /// Maximum value + int32 MaxValue() const + { + return Math::Max(X, Y); + } + + + // Returns a vector containing the smallest components of the specified vectors + // @param a The first source vector + // @param b The second source vector static Int2 Min(const Int2& a, const Int2& b) { return Int2(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y);