summaryrefslogtreecommitdiff
path: root/Runtime/Math/Vector2.h
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Math/Vector2.h')
-rw-r--r--Runtime/Math/Vector2.h17
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;