diff options
author | chai <chaifix@163.com> | 2021-11-03 09:52:26 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-03 09:52:26 +0800 |
commit | c10e0d92f46e5eaf25a69e1fafe5f4dbd8eaab9d (patch) | |
tree | 2eb1a91339b35fea68f48b2774355f496519db83 /Runtime/Math/Vector2.h | |
parent | 3898f2c648b1a731dead8337aad8912d2b8b80d7 (diff) |
*misc
Diffstat (limited to 'Runtime/Math/Vector2.h')
-rw-r--r-- | Runtime/Math/Vector2.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Runtime/Math/Vector2.h b/Runtime/Math/Vector2.h index 27cf312..9d7e4e9 100644 --- a/Runtime/Math/Vector2.h +++ b/Runtime/Math/Vector2.h @@ -1,4 +1,6 @@ #pragma once +#include "MathHelper.h" +#include "Runtime/Utilities/Assert.h" namespace Internal { @@ -15,6 +17,21 @@ namespace Internal this->y = y; } + Vector2 Clamp(float xmin, float xmax, float ymin, float ymax) + { + Vector2 v; + v.x = clamp(x, xmin, xmax); + v.y = clamp(y, ymin, ymax); + return v; + } + + float operator[](int i) + { + if (i == 0) return x; + else if (i == 1) return y; + Assert(false); + } + bool operator == (const Vector2& v) const { return v.x == x && v.y == y; |