aboutsummaryrefslogtreecommitdiff
path: root/umath/vec2.h
diff options
context:
space:
mode:
authorjacopograndi <jak.sk8@hotmail.it>2021-08-19 18:46:51 +0200
committerjacopograndi <jak.sk8@hotmail.it>2021-08-19 18:46:51 +0200
commita8bcacc95045102e67f2feabbdddf79535837554 (patch)
tree5781dd4cb2fe66b67deab84ff4641b7e21b9c174 /umath/vec2.h
forgot to make repo until now
Diffstat (limited to 'umath/vec2.h')
-rw-r--r--umath/vec2.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/umath/vec2.h b/umath/vec2.h
new file mode 100644
index 0000000..ee72143
--- /dev/null
+++ b/umath/vec2.h
@@ -0,0 +1,33 @@
+#ifndef VEC2_H
+#define VEC2_H
+
+class vec2 {
+ public:
+ float x;
+ float y;
+
+ vec2() : x(0), y(0) {};
+ vec2(float x, float y) : x(x), y(y) {};
+
+ vec2(const vec2 &oth) { x = oth.x; y = oth.y; };
+ vec2(vec2 &oth) { x = oth.x; y = oth.y; };
+
+ vec2 operator+(const vec2 &rhs) {
+ return vec2 { x + rhs.x, y + rhs.y };
+ }
+ vec2 operator-(const vec2 &rhs) {
+ return vec2 { x - rhs.x, y - rhs.y };
+ }
+ vec2 operator*(const float m) {
+ return vec2 { x * m, y * m };
+ }
+ vec2 operator/(const float m) {
+ return vec2 { x / m, y / m };
+ }
+ vec2 operator+=(vec2 oth) { x += oth.x; y += oth.y; }
+ vec2 operator-=(vec2 oth) { x -= oth.x; y -= oth.y; }
+ vec2 operator*=(float m) { x *= m; y *= m; }
+ vec2 operator/=(float m) { x /= m; y /= m; }
+};
+
+#endif \ No newline at end of file