summaryrefslogtreecommitdiff
path: root/Source/modules/asura-base/Math/Vector2.inc
diff options
context:
space:
mode:
Diffstat (limited to 'Source/modules/asura-base/Math/Vector2.inc')
-rw-r--r--Source/modules/asura-base/Math/Vector2.inc114
1 files changed, 114 insertions, 0 deletions
diff --git a/Source/modules/asura-base/Math/Vector2.inc b/Source/modules/asura-base/Math/Vector2.inc
new file mode 100644
index 0000000..155432a
--- /dev/null
+++ b/Source/modules/asura-base/Math/Vector2.inc
@@ -0,0 +1,114 @@
+template <typename T>
+inline Vector2<T>::Vector2() :
+ x(0),
+ y(0)
+{
+
+}
+
+template <typename T>
+inline Vector2<T>::Vector2(T X, T Y) :
+ x(X),
+ y(Y)
+{
+
+}
+
+template <typename T>
+template <typename U>
+inline Vector2<T>::Vector2(const Vector2<U>& vector) :
+ x(static_cast<T>(vector.x)),
+ y(static_cast<T>(vector.y))
+{
+}
+
+template <typename T>
+inline void Vector2<T>::Set(T X, T Y)
+{
+ x = X;
+ y = Y;
+}
+
+template <typename T>
+inline Vector2<T> operator -(const Vector2<T>& right)
+{
+ return Vector2<T>(-right.x, -right.y);
+}
+
+template <typename T>
+inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)
+{
+ left.x += right.x;
+ left.y += right.y;
+
+ return left;
+}
+
+template <typename T>
+inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)
+{
+ left.x -= right.x;
+ left.y -= right.y;
+
+ return left;
+}
+
+template <typename T>
+inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)
+{
+ return Vector2<T>(left.x + right.x, left.y + right.y);
+}
+
+template <typename T>
+inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)
+{
+ return Vector2<T>(left.x - right.x, left.y - right.y);
+}
+
+template <typename T>
+inline Vector2<T> operator *(const Vector2<T>& left, T right)
+{
+ return Vector2<T>(left.x * right, left.y * right);
+}
+
+template <typename T>
+inline Vector2<T> operator *(T left, const Vector2<T>& right)
+{
+ return Vector2<T>(right.x * left, right.y * left);
+}
+
+template <typename T>
+inline Vector2<T>& operator *=(Vector2<T>& left, T right)
+{
+ left.x *= right;
+ left.y *= right;
+
+ return left;
+}
+
+template <typename T>
+inline Vector2<T> operator /(const Vector2<T>& left, T right)
+{
+ return Vector2<T>(left.x / right, left.y / right);
+}
+
+template <typename T>
+inline Vector2<T>& operator /=(Vector2<T>& left, T right)
+{
+ left.x /= right;
+ left.y /= right;
+
+ return left;
+}
+
+template <typename T>
+inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right)
+{
+ return (left.x == right.x) && (left.y == right.y);
+}
+
+template <typename T>
+inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right)
+{
+ return (left.x != right.x) || (left.y != right.y);
+}