X-Git-Url: http://git.localhorst.tv/?p=space.git;a=blobdiff_plain;f=src%2Fmath%2FVector.h;fp=src%2Fmath%2FVector.h;h=b5c6d7d11dd9f9452c0a65b781a511b8fa9603ad;hp=57159bff2e0e01193e4a8ea16952eace97e9e4b7;hb=2d0a41dc0a53915153ceccda914d59affd388864;hpb=3f4f8a92f64df08119a40da4d196b3e92ecdc637 diff --git a/src/math/Vector.h b/src/math/Vector.h index 57159bf..b5c6d7d 100644 --- a/src/math/Vector.h +++ b/src/math/Vector.h @@ -2,6 +2,7 @@ #define SPACE_VECTOR_H_ #include +#include namespace space { @@ -66,6 +67,37 @@ 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 << '>'; +} + }