aboutsummaryrefslogtreecommitdiff
path: root/src/math/vector.h
diff options
context:
space:
mode:
authorvimene <vincent.menegaux@gmail.com>2023-12-03 09:16:18 +0100
committervimene <vincent.menegaux@gmail.com>2023-12-03 09:16:18 +0100
commit5a8bc0a4936cdd461c43740437541f8c991ff117 (patch)
tree6c4c5c262eb032711f5517cbe035e693377f76c4 /src/math/vector.h
parent7b82aa798a95d93e9c4361dfed12d2a5313e01cb (diff)
downloadengine-5a8bc0a4936cdd461c43740437541f8c991ff117.tar.gz
renamed math_vector.{h,cpp} to vector.{h,cpp}
Diffstat (limited to 'src/math/vector.h')
-rw-r--r--src/math/vector.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/math/vector.h b/src/math/vector.h
new file mode 100644
index 0000000..28ae81e
--- /dev/null
+++ b/src/math/vector.h
@@ -0,0 +1,73 @@
+#ifndef MATH_MATH_VECTOR_H
+#define MATH_MATH_VECTOR_H
+
+namespace engine::math {
+
+class MathVector2 {
+ public:
+ float x, y;
+
+ MathVector2();
+ MathVector2(float x, float y);
+ bool operator==(MathVector2 other) const;
+ bool operator!=(MathVector2 other) const;
+ MathVector2 operator+() const;
+ MathVector2 operator-() const;
+ MathVector2 operator+(MathVector2 other) const;
+ MathVector2 operator-(MathVector2 other) const;
+ float det(MathVector2 other) const;
+ MathVector2 round() const;
+};
+
+MathVector2 operator*(float n, MathVector2 other);
+MathVector2 operator*(MathVector2 other, float n);
+MathVector2 operator/(MathVector2 other, float n);
+
+class MathVector3 {
+ public:
+ float x, y, z;
+
+ MathVector3();
+ MathVector3(float x, float y, float z);
+ bool operator==(MathVector3 other) const;
+ bool operator!=(MathVector3 other) const;
+ MathVector3 operator+() const;
+ MathVector3 operator-() const;
+ MathVector3 operator+(MathVector3 other) const;
+ MathVector3 operator-(MathVector3 other) const;
+ MathVector3 round() const;
+ MathVector2 xy() const;
+ MathVector3 cross(MathVector3 other) const;
+};
+
+MathVector3 operator*(float n, MathVector3 other);
+MathVector3 operator*(MathVector3 other, float n);
+MathVector3 operator/(MathVector3 other, float n);
+
+class MathVector4 {
+ public:
+ float x, y, z, w;
+
+ MathVector4();
+ MathVector4(float x, float y, float z, float w);
+ MathVector4(float x, float y, float z);
+ MathVector4(MathVector3 v, float w);
+ MathVector4(MathVector3 v);
+ bool operator==(MathVector4 other) const;
+ bool operator!=(MathVector4 other) const;
+ MathVector4 operator+() const;
+ MathVector4 operator-() const;
+ MathVector4 operator+(MathVector4 other) const;
+ MathVector4 operator-(MathVector4 other) const;
+ MathVector4 round() const;
+ MathVector3 xyz() const;
+ MathVector3 div_by_w() const;
+};
+
+MathVector4 operator*(float n, MathVector4 other);
+MathVector4 operator*(MathVector4 other, float n);
+MathVector4 operator/(MathVector4 other, float n);
+
+}
+
+#endif // MATH_MATH_VECTOR_H