X-Git-Url: http://git.localhorst.tv/?p=space.git;a=blobdiff_plain;f=src%2Fmath%2FVector.h;fp=src%2Fmath%2FVector.h;h=0000000000000000000000000000000000000000;hp=b5c6d7d11dd9f9452c0a65b781a511b8fa9603ad;hb=61c2d30a60d586cbe63885885c6a373c7713af1e;hpb=08d0e47634e1632c96ebe3308535a86f5e625b40 diff --git a/src/math/Vector.h b/src/math/Vector.h deleted file mode 100644 index b5c6d7d..0000000 --- a/src/math/Vector.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef SPACE_VECTOR_H_ -#define SPACE_VECTOR_H_ - -#include -#include - - -namespace space { - -template -class Vector { - -public: - constexpr Vector() : x(0), y(0) { } - constexpr Vector(Scalar x, Scalar y) : x(x), y(y) { } - - template - constexpr Vector(Vector other) : x(other.x), y(other.y) { } - -public: - Vector &operator +=(Vector other) { - x += other.x; - y += other.y; - return *this; - } - Vector &operator -=(Vector other) { - x -= other.x; - y -= other.y; - return *this; - } - -public: - Scalar x; - Scalar y; - -}; - - -template -constexpr Vector operator -(Vector v) { - return Vector(-v.x, -v.y); -} - - -template -constexpr Vector operator +(Vector lhs, Vector rhs) { - return Vector(lhs.x + rhs.x, lhs.y + rhs.y); -} - -template -constexpr Vector operator -(Vector lhs, Vector rhs) { - return Vector(lhs.x - rhs.x, lhs.y - rhs.y); -} - - -template -constexpr Vector operator *(Vector lhs, Scalar rhs) { - return Vector(lhs.x * rhs, lhs.y * rhs); -} - -template -constexpr Vector operator *(Scalar lhs, Vector rhs) { - return rhs * lhs; -} -template -constexpr Vector operator *(Vector lhs, Vector rhs) { - return Vector(lhs.x * rhs.x, lhs.y * rhs.y); -} - - -template -constexpr Vector operator /(Vector lhs, Scalar rhs) { - return Vector(lhs.x / rhs, lhs.y / rhs); -} - -template -constexpr Vector operator /(Scalar lhs, Vector rhs) { - return rhs / lhs; -} -template -constexpr Vector operator /(Vector lhs, Vector rhs) { - return Vector(lhs.x / rhs.x, lhs.y / rhs.y); -} - - -template -constexpr bool operator ==(Vector lhs, Vector rhs) { - return lhs.x == rhs.x && lhs.y == rhs.y; -} -template -constexpr bool operator !=(Vector lhs, Vector rhs) { - return lhs.x != rhs.x && lhs.y != rhs.y; -} - - -template -inline std::ostream &operator <<(std::ostream &out, Vector v) { - return out << '<' << v.x << ',' << v.y << '>'; -} - -} - - -namespace std { - -template -constexpr space::Vector min( - space::Vector lhs, - space::Vector rhs -) { - return space::Vector( - min(lhs.x, rhs.x), - min(lhs.y, rhs.y) - ); -} - -template -constexpr space::Vector max( - space::Vector lhs, - space::Vector rhs -) { - return space::Vector( - max(lhs.x, rhs.x), - max(lhs.y, rhs.y) - ); -} - -} - -#endif