#ifndef SDLPP_HPP_VECTOR #define SDLPP_HPP_VECTOR #include "sdlpp_common.hpp" namespace SDLPP { template class SDLPPSCOPE Vec2D { public: Vec2D() = default; ~Vec2D() = default; Vec2D(T x, T y) : _x(x), _y(y) {} T getX() const { return _x; } T getY() const { return _y; } Vec2D operator-(const Vec2D &other) const { return Vec2D( getX() - other.getX(), getY() - other.getY() ); } Vec2D operator+(const Vec2D &other) const { return Vec2D( getX() + other.getX(), getY() + other.getY() ); } Vec2D operator*(double multiplier) const { return Vec2D( getX() * multiplier, getY() * multiplier ); } Vec2D operator/(double divisor) const { return *this * ( 1.0 / divisor ); } T operator*(const Vec2D &other) const { return getX() * other.getX() + getY() * other.getY(); } Vec2D &operator+=(const Vec2D &other) { *this = *this + other; return *this; } Vec2D &operator-=(const Vec2D &other) { *this = *this - other; return *this; } private: T _x = 0.0; T _y = 0.0; }; template Vec2D operator*(double multiplier, const Vec2D &vec) { return vec * multiplier; } template Vec2D operator/(double divisor, const Vec2D &vec) { return vec / divisor; } } #endif