aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/math/vector3.hpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-01-12 21:48:33 +0800
committerchai <chaifix@163.com>2019-01-12 21:48:33 +0800
commit8b00d67febf133e89f6a0bfabc41feed555dc4a9 (patch)
treefe48ef17c250afa40c2588300fcdb5920dba6951 /src/libjin/math/vector3.hpp
parenta907c39756ef6b368d06643afa491c49a9044a8e (diff)
*去掉文件前缀je_
Diffstat (limited to 'src/libjin/math/vector3.hpp')
-rw-r--r--src/libjin/math/vector3.hpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/libjin/math/vector3.hpp b/src/libjin/math/vector3.hpp
new file mode 100644
index 0000000..3c800b6
--- /dev/null
+++ b/src/libjin/math/vector3.hpp
@@ -0,0 +1,51 @@
+#ifndef __JE_VECTOR3_H__
+#define __JE_VECTOR3_H__
+
+namespace JinEngine
+{
+ 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];
+ }
+
+ #define _aliases(A, B, C) \
+ inline T& A() { return data[0]; }\
+ inline T& B() { return data[1]; }\
+ inline T& C() { return data[2]; }\
+ inline T A() const { return data[0]; }\
+ inline T B() const { return data[1]; }\
+ inline T C() const { return data[2]; }
+
+ _aliases(x, y, z);
+ _aliases(r, g, b);
+
+ #undef _aliases
+
+ private:
+ T data[3];
+
+ };
+
+ } // namespace Math
+} // namespace JinEngine
+
+#endif \ No newline at end of file