]> git.tdb.fi Git - libs/math.git/commitdiff
Add a Vector2 class
authorMikko Rasa <tdb@tdb.fi>
Tue, 14 May 2013 20:11:38 +0000 (23:11 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 14 May 2013 20:11:38 +0000 (23:11 +0300)
source/linal/dummy.cpp
source/linal/vector2.h [new file with mode: 0644]

index 28e681aa1488595f24566cb4accf71d5bb3e4750..25e76a37199cce8ec29c7fdd4bf72fadcbef5242 100644 (file)
@@ -1,9 +1,8 @@
 #include "vector.h"
+#include "vector2.h"
 #include "vector3.h"
 #include "matrix.h"
 #include "squarematrix.h"
-#include "matrix4.h"
 
 /* This dummy file is needed to make Builder happy, and also serves as a syntax
 check by pulling in all the headers. */
-void dummy() { }
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