aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Math
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Math')
-rw-r--r--src/libjin/Math/Vector2.cpp9
-rw-r--r--src/libjin/Math/Vector2.h29
-rw-r--r--src/libjin/Math/Vector2.hpp39
-rw-r--r--src/libjin/Math/Vector3.hpp41
-rw-r--r--src/libjin/Math/Vector4.hpp44
5 files changed, 124 insertions, 38 deletions
diff --git a/src/libjin/Math/Vector2.cpp b/src/libjin/Math/Vector2.cpp
deleted file mode 100644
index 737c496..0000000
--- a/src/libjin/Math/Vector2.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "Vector2.h"
-
-namespace jin
-{
-namespace math
-{
-
-} // math
-} // jin \ No newline at end of file
diff --git a/src/libjin/Math/Vector2.h b/src/libjin/Math/Vector2.h
deleted file mode 100644
index ce96ac8..0000000
--- a/src/libjin/Math/Vector2.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __JIN_VECTOR_H
-#define __JIN_VECTOR_H
-
-namespace jin
-{
-namespace math
-{
-
- template<typename T>
- class Vector2
- {
- public:
- Vector2() : x(0), y(0) {};
- Vector2(T _x, T _y) :x(_x), y(_y) {};
- Vector2(const Vector2<T>& v)
- {
- x = v.x;
- y = v.y;
- }
-
- T x;
- T y;
-
- };
-
-} // math
-} // jin
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Math/Vector2.hpp b/src/libjin/Math/Vector2.hpp
new file mode 100644
index 0000000..a657c83
--- /dev/null
+++ b/src/libjin/Math/Vector2.hpp
@@ -0,0 +1,39 @@
+#ifndef __JIN_VECTOR_H
+#define __JIN_VECTOR_H
+
+namespace jin
+{
+namespace math
+{
+
+ template<typename T>
+ class Vector2
+ {
+ public:
+ Vector2()
+ {
+ data[0] = data[1] = 0;
+ }
+ Vector2(T _x, T _y)
+ {
+ data[0] = _x;
+ data[1] = _y;
+ }
+ Vector2(const Vector2<T>& v)
+ {
+ data[0] = v.data[0];
+ data[1] = v.data[1];
+ }
+
+ T &x = data[0], &y = data[1]; // xy
+ T &w = data[0], &h = data[1]; // wh
+
+ private:
+ T data[2];
+
+ };
+
+} // math
+} // jin
+
+#endif \ No newline at end of file
diff --git a/src/libjin/Math/Vector3.hpp b/src/libjin/Math/Vector3.hpp
new file mode 100644
index 0000000..846dea8
--- /dev/null
+++ b/src/libjin/Math/Vector3.hpp
@@ -0,0 +1,41 @@
+#ifndef __JIN_VECTOR3_H
+#define __JIN_VECTOR3_H
+
+namespace jin
+{
+namespace math
+{
+
+ template<typename T>
+ class Vector3
+ {
+ public:
+ Vector3()
+ {
+ data[0] = data[1] = data[2] = 0;
+ }
+ Vector3(T _x, T _y, T _z)
+ {
+ data[0] = _x;
+ data[1] = _y;
+ data[2] = _z;
+ }
+ Vector3(const Vector3<T>& v)
+ {
+ data[0] = v.data[0];
+ data[1] = v.data[1];
+ data[2] = v.data[2];
+ }
+
+ T &x = data[0], &y = data[1], &z = data[2]; // xyz
+ T &r = data[0], &g = data[1], &b = data[2]; // rgb
+
+ private:
+ T data[3];
+
+ };
+
+} // math
+} // jin
+
+#endif \ No newline at end of file
diff --git a/src/libjin/Math/Vector4.hpp b/src/libjin/Math/Vector4.hpp
new file mode 100644
index 0000000..e869ddf
--- /dev/null
+++ b/src/libjin/Math/Vector4.hpp
@@ -0,0 +1,44 @@
+#ifndef __JIN_VECTOR4_H
+#define __JIN_VECTOR4_H
+
+namespace jin
+{
+namespace math
+{
+
+ template<typename T>
+ class Vector4
+ {
+ public:
+ Vector4()
+ {
+ data[0] = data[1] = data[2] = data[3] = 0;
+ }
+ Vector4(T _x, T _y, T _z, T _t)
+ {
+ data[0] = _x;
+ data[1] = _y;
+ data[2] = _z;
+ data[3] = _t;
+ }
+ Vector4(const Vector4<T>& v)
+ {
+ data[0] = v.data[0];
+ data[1] = v.data[1];
+ data[2] = v.data[2];
+ data[3] = v.data[3];
+ }
+
+ T &x = data[0], &y = data[1], &z = data[2], &t = data[3]; // xyzt
+ T &w = data[2], &h = data[3]; // xywh
+ T &r = data[0], &g = data[1], &b = data[2], &a = data[3]; // rgb
+
+ private:
+ T data[4];
+
+ };
+
+} // math
+} // jin
+
+#endif \ No newline at end of file