Add Int2 Min/Max.

This commit is contained in:
Jean-Baptiste Perrier
2021-04-08 18:54:35 +02:00
parent 9d3861ace2
commit e912590bc6

View File

@@ -361,11 +361,31 @@ public:
return Int2(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y);
}
// Creates vector from maximum components of two vectors
// Returns a vector containing the largest components of the specified vectors
// @param a The first source vector
// @param b The second source vector
static Int2 Max(const Int2& a, const Int2& b)
{
return Int2(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y);
}
// Returns a vector containing the smallest components of the specified vectors
// @param a The first source vector
// @param b The second source vector
// @param result When the method completes, contains an new vector composed of the smallest components of the source vectors
static void Min(const Int2& a, const Int2& b, Int2& result)
{
result = Int2(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y);
}
// Returns a vector containing the largest components of the specified vectors
// @param a The first source vector
// @param b The second source vector
// @param result When the method completes, contains an new vector composed of the largest components of the source vectors
static void Max(const Int2& a, const Int2& b, Int2& result)
{
result = Int2(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y);
}
};
template<>