KlassischeKeplerKriege/KKK/game/include/vector.h

52 lines
994 B
C
Raw Normal View History

#pragma once
struct Vec2d
{
double x;
double y;
Vec2d & operator+=(const Vec2d& rhs) {
x+=rhs.x;
y+=rhs.y;
return *this;
}
Vec2d & operator-=(const Vec2d& rhs) {
x-=rhs.x;
y-=rhs.y;
return *this;
}
Vec2d & operator*=(const double& rhs) {
x*=rhs;
y*=rhs;
return *this;
}
Vec2d & operator/=(const double& rhs) {
x/=rhs;
y/=rhs;
return *this;
}
const Vec2d operator+(const Vec2d& rhs) const {
Vec2d result = *this;
result += rhs;
return result;
}
const Vec2d operator-(const Vec2d& rhs) const {
Vec2d result = *this;
result -= rhs;
return result;
}
const double operator*(const Vec2d& rhs) const {
return (this->x * rhs.x) + (this->y * rhs.y);
}
const Vec2d operator*(const double& rhs) const {
Vec2d result = *this;
result *= rhs;
return result;
}
const Vec2d operator/(const double& rhs) const {
Vec2d result = *this;
result /= rhs;
return result;
}
};