summaryrefslogtreecommitdiffstats
path: root/engine/include/symbasic/svector.hpp
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2019-01-25 01:11:57 +0100
committerNao Pross <naopross@thearcway.org>2019-01-25 01:11:57 +0100
commitbcd14a356cafe58808b4c2a14782ebb194c6abc5 (patch)
tree3bc95288b0a0172bb447ccf218fb59821f22501a /engine/include/symbasic/svector.hpp
parentDelete bin and test/makefile update .gitignore (diff)
downloadflatland-bcd14a356cafe58808b4c2a14782ebb194c6abc5.tar.gz
flatland-bcd14a356cafe58808b4c2a14782ebb194c6abc5.zip
Rename everything under engine/ to remove `flat' and be `.hpp'
Diffstat (limited to 'engine/include/symbasic/svector.hpp')
-rw-r--r--engine/include/symbasic/svector.hpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/engine/include/symbasic/svector.hpp b/engine/include/symbasic/svector.hpp
new file mode 100644
index 0000000..c53ae0f
--- /dev/null
+++ b/engine/include/symbasic/svector.hpp
@@ -0,0 +1,78 @@
+#ifndef __STATIC_VECTOR_H__
+#define __STATIC_VECTOR_H__
+
+#include <array>
+#include "vector.h"
+
+template<class T, std::size_t N>
+class SVector : public Vector<T>
+{
+
+public:
+
+ /* Constructors */
+
+ SVector(const T &value = T());
+ SVector(const std::initializer_list<T> &init);
+ SVector(const SVector<T, N>&);
+
+ SVector& operator=(const SVector<T, N>&);
+
+ virtual const size_t size() const override;
+
+ virtual T& operator[](size_t i) override;
+ virtual const T& operator[](size_t i) const override;
+
+ /* Plus / minus */
+ SVector<T, N>& operator+=(const Vector<T>&);
+ SVector<T, N>& operator-=(const Vector<T>&);
+
+ /* Scalar multiplication / division */
+ SVector<T, N>& operator*=(double k);
+ SVector<T, N>& operator/=(double k);
+
+ /* Reverse operator */
+ SVector<T, N>& operator~();
+
+ /* Unit vector */
+ SVector<T, N>& unit();
+
+private:
+
+ std::array<T, N> components;
+};
+
+template<class T, std::size_t N>
+const SVector<T, N> operator+(SVector<T, N> , const Vector<T>& );
+
+template<class T, std::size_t N>
+const SVector<T, N> operator-(SVector<T, N> , const Vector<T>& );
+
+template<class T, std::size_t N>
+const SVector<T, N> operator*(SVector<T, N> , double);
+
+template<class T, std::size_t N>
+const SVector<T, N> operator/(SVector<T, N> , double);
+
+template<class T, std::size_t N>
+const SVector<T, N> operator*(double, SVector<T, N>);
+
+template<class T, std::size_t N>
+const SVector<T, N> operator/(double, SVector<T, N>);
+
+template<class T, std::size_t N>
+const SVector<T, N> operator-(SVector<T, N>);
+
+/*
+ * Prototipe for cross product
+ */
+inline const SVector<double, 3> operator^(const SVector<double, 3>& v, const SVector<double, 3>& w);
+inline double operator^(const SVector<double, 2>& v, const SVector<double, 2>& w);
+inline double operator^(const SVector<double, 1>& v, const SVector<double, 1>& w);
+
+/*
+ * Include definitions file
+ */
+#include "svector.tpp"
+
+#endif // __SVECTOR_H__