-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdlas.hpp
49 lines (34 loc) · 1.09 KB
/
sdlas.hpp
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
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <cmath>
class Vector2{ public: int x; int y; float magnitude(){ return sqrt(pow(x, 2) + pow(y, 2)); }; };
class Vector2f{ public: float x; float y; float magnitude(){ return sqrt(pow(x, 2) + pow(y, 2)); }; };
Vector2 operator+(Vector2 a, Vector2 b){
return Vector2{a.x + b.x, a.y + b.y};
}
Vector2 operator-(Vector2 a, Vector2 b){
return Vector2{a.x - b.x, a.y - b.y};
}
Vector2 operator*(Vector2 a, Vector2 b){
return Vector2{a.x * b.x, a.y * b.y};
}
Vector2 operator/(Vector2 a, Vector2 b){
return Vector2{a.x / b.x, a.y / b.y};
}
Vector2f operator+(Vector2f a, Vector2f b){
return Vector2f{a.x + b.x, a.y + b.y};
}
Vector2f operator+=(Vector2f a, Vector2f b){
return Vector2f{a.x + b.x, a.y + b.y};
}
Vector2f operator-(Vector2f a, Vector2f b){
return Vector2f{a.x - b.x, a.y - b.y};
}
Vector2f operator*(Vector2f a, Vector2f b){
return Vector2f{a.x * b.x, a.y * b.y};
}
Vector2f operator*(Vector2f a, float b){
return Vector2f{a.x * b, a.y * b};
}
Vector2f operator/(Vector2f a, Vector2f b){
return Vector2f{a.x / b.x, a.y / b.y};
}