diff options
Diffstat (limited to 'vendor/quadtree/Vector2.h')
-rw-r--r-- | vendor/quadtree/Vector2.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/vendor/quadtree/Vector2.h b/vendor/quadtree/Vector2.h new file mode 100644 index 0000000..302d73e --- /dev/null +++ b/vendor/quadtree/Vector2.h | |||
@@ -0,0 +1,47 @@ | |||
1 | #pragma once | ||
2 | |||
3 | namespace quadtree | ||
4 | { | ||
5 | |||
6 | template<typename T> | ||
7 | class Vector2 | ||
8 | { | ||
9 | public: | ||
10 | T x; | ||
11 | T y; | ||
12 | |||
13 | constexpr Vector2<T>(T X = 0, T Y = 0) noexcept : x(X), y(Y) | ||
14 | { | ||
15 | |||
16 | } | ||
17 | |||
18 | constexpr Vector2<T>& operator+=(const Vector2<T>& other) noexcept | ||
19 | { | ||
20 | x += other.x; | ||
21 | y += other.y; | ||
22 | return *this; | ||
23 | } | ||
24 | |||
25 | constexpr Vector2<T>& operator/=(T t) noexcept | ||
26 | { | ||
27 | x /= t; | ||
28 | y /= t; | ||
29 | return *this; | ||
30 | } | ||
31 | }; | ||
32 | |||
33 | template<typename T> | ||
34 | constexpr Vector2<T> operator+(Vector2<T> lhs, const Vector2<T>& rhs) noexcept | ||
35 | { | ||
36 | lhs += rhs; | ||
37 | return lhs; | ||
38 | } | ||
39 | |||
40 | template<typename T> | ||
41 | constexpr Vector2<T> operator/(Vector2<T> vec, T t) noexcept | ||
42 | { | ||
43 | vec /= t; | ||
44 | return vec; | ||
45 | } | ||
46 | |||
47 | } | ||