dungeon/src/vec2i.h

49 lines
716 B
C
Raw Normal View History

2017-09-17 13:43:13 +02:00
#pragma once
2017-09-26 15:49:11 +02:00
#include <cmath>
2017-09-17 13:43:13 +02:00
struct vec2i {
int x, y;
vec2i() {
this->x = 0;
this->y = 0;
}
vec2i(int x, int y) {
this->x = x;
this->y = y;
}
2017-09-26 15:49:11 +02:00
double dist() {
return sqrt(dist_squared());
}
int dist_squared() {
return x*x + y*y;
}
2017-09-17 13:43:13 +02:00
bool operator==(vec2i a) {
return a.x == x && a.y == y;
}
bool operator!=(vec2i a) {
return a.x != x || a.y != y;
}
vec2i operator+(vec2i a) {
return { x + a.x, y + a.y };
}
vec2i operator-(vec2i a) {
return { x - a.x, y - a.y };
}
vec2i operator*(vec2i a) {
return { x*a.x, y*a.y };
}
vec2i operator*(int a) {
return{ x*a, y*a };
}
};