summaryrefslogtreecommitdiffstats
path: root/engine/include/symbasic/svector.h
diff options
context:
space:
mode:
Diffstat (limited to 'engine/include/symbasic/svector.h')
-rw-r--r--engine/include/symbasic/svector.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/engine/include/symbasic/svector.h b/engine/include/symbasic/svector.h
new file mode 100644
index 0000000..c53ae0f
--- /dev/null
+++ b/engine/include/symbasic/svector.h
@@ -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__