#ifndef _HEADER_TEA_MATH_VECTOR2 #define _HEADER_TEA_MATH_VECTOR2 namespace TeaLib { namespace Math { template class Vector2 { public: Vector2() : x(0), y(0){}; Vector2(const T a_X, const T a_Y) : x(a_X), y(a_Y){}; Vector2& operator+=(const Vector2& rhs) { this->x += rhs.x; this->y += rhs.y; return *this; } Vector2& operator-=(const Vector2& rhs) { this->x -= rhs.x; this->y -= rhs.y; return *this; } Vector2& operator*=(const float& rhs) { this->x *= rhs; this->y *= rhs; return *this; } Vector2& operator/=(const float& rhs) { this->x /= rhs; this->y /= rhs; return *this; } Vector2 operator+(const Vector2& rhs) { Vector2 retVal; retVal.x = this->x + rhs.x; retVal.y = this->y + rhs.y; return retVal; } Vector2 operator-(const Vector2& rhs) { Vector2 retVal; retVal.x = this->x - rhs.x; retVal.y = this->y - rhs.y; return retVal; } Vector2 operator*(const float& rhs) { Vector2 retVal; retVal.x = this->x * rhs; retVal.y = this->y * rhs; return retVal; } Vector2 operator/(const float& rhs) { Vector2 retVal; retVal.x = this->x / rhs; retVal.y = this->y / rhs; return retVal; } bool operator==(const Vector2& rhs) { return ((this->x == rhs.x) && (this->y == rhs.y)); } float LengthSquared() { return ((x*x) + (y*y)); } float Length() { return sqrtf(LengthSquared()); } T x, y; }; typedef Vector2 Vector2f; typedef Vector2 Vector2i; typedef Vector2 Vector2u; }; }; #endif