]> git.tdb.fi Git - libs/math.git/blobdiff - source/linal/vector2.h
Add a Vector2 class
[libs/math.git] / source / linal / vector2.h
diff --git a/source/linal/vector2.h b/source/linal/vector2.h
new file mode 100644 (file)
index 0000000..fed7721
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef MSP_LINAL_VECTOR2_H_
+#define MSP_LINAL_VECTOR2_H_
+
+#include "vector.h"
+
+namespace Msp {
+namespace LinAl {
+
+template<typename T>
+class Vector2: public Vector<T, 2>
+{
+public:
+       Vector2() { }
+       Vector2(const T *d): Vector<T, 2>(d) { }
+       Vector2(T, T);
+       template<typename U>
+       Vector2(const Vector<U, 2> &v): Vector<T, 2>(v) { }
+};
+
+template<typename T>
+inline Vector2<T>::Vector2(T x, T y)
+{
+       this->data[0] = x;
+       this->data[1] = y;
+}
+
+} // namespace LinAl
+} // namespace Msp
+
+#endif