blob: a9de66245cfc1d9c69f7b9f594d206b1eb0ae957 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#ifndef MGLPP_VEC_HPP
#define MGLPP_VEC_HPP
namespace mgl {
template <typename T>
struct vec2 {
vec2(T x = 0, T y = 0) : x(x), y(y) {}
vec2<T> operator + (vec2<T> other) const {
return { x + other.x, y + other.y };
}
vec2<T> operator - (vec2<T> other) const {
return { x - other.x, y - other.y };
}
vec2<T> operator * (vec2<T> other) const {
return { x * other.x, y * other.y };
}
vec2<T> operator * (T v) const {
return { x * v, y * v };
}
vec2<float> to_vec2f() const {
return { (float)x, (float)y };
}
T x;
T y;
};
using vec2f = vec2<float>;
using vec2d = vec2<double>;
using vec2i = vec2<int>;
using vec2u = vec2<unsigned int>;
}
#endif /* MGLPP_VEC_HPP */
|