From 250e30d73f09e9da2b5a81d0fbae63744ae12a73 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 2 Apr 2019 08:47:15 +0800 Subject: *misc --- source/libs/asura-lib-utils/math/vector2.hpp | 70 ++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 source/libs/asura-lib-utils/math/vector2.hpp (limited to 'source/libs/asura-lib-utils/math/vector2.hpp') diff --git a/source/libs/asura-lib-utils/math/vector2.hpp b/source/libs/asura-lib-utils/math/vector2.hpp new file mode 100644 index 0000000..df78255 --- /dev/null +++ b/source/libs/asura-lib-utils/math/vector2.hpp @@ -0,0 +1,70 @@ +#ifndef __ASURA_ENGINE_VECTOR2_H__ +#define __ASURA_ENGINE_VECTOR2_H__ + +namespace AsuraEngine +{ + namespace Math + { + template + class Vector2 + { + public: + Vector2(); + Vector2(T X, T Y); + + template + explicit Vector2(const Vector2& vector); + + Set(T X, T Y); + + T x; ///< X coordinate of the vector + T y; ///< Y coordinate of the vector + }; + + template + Vector2 operator -(const Vector2& right); + + template + Vector2& operator +=(Vector2& left, const Vector2& right); + + template + Vector2& operator -=(Vector2& left, const Vector2& right); + + template + Vector2 operator +(const Vector2& left, const Vector2& right); + + template + Vector2 operator -(const Vector2& left, const Vector2& right); + + template + Vector2 operator *(const Vector2& left, T right); + + template + Vector2 operator *(T left, const Vector2& right); + + template + Vector2& operator *=(Vector2& left, T right); + + template + Vector2 operator /(const Vector2& left, T right); + + template + Vector2& operator /=(Vector2& left, T right); + + template + bool operator ==(const Vector2& left, const Vector2& right); + + template + bool operator !=(const Vector2& left, const Vector2& right); + +#include "Vector2.inl" + + // Define the most common types + typedef Vector2 Vector2i; + typedef Vector2 Vector2u; + typedef Vector2 Vector2f; + + } +} + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0