]> git.localhorst.tv Git - l2e.git/blobdiff - src/math/Vector.h
added fixed point number type
[l2e.git] / src / math / Vector.h
index fb07d338986fa2f4b9c0373bc808b911efd18ec0..6cb9ba333ba33cb7974f80cc76d9265de6e55d56 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef MATH_VECTOR_H_
 #define MATH_VECTOR_H_
 
+#include "Fixed.h"
+
 #include <cmath>
 #include <limits>
 #include <ostream>
@@ -16,7 +18,7 @@ public:
        Vector() : x(0), y(0) { }
        Vector(Scalar x, Scalar y) : x(x), y(y) { }
        template<class T>
-       Vector(const Vector<T> &other) : x(other.X()), y(other.Y()) { };
+       Vector(const Vector<T> &other) : x(other.X()), y(other.Y()) { }
        template<class T>
        Vector(T x, T y) : x(x), y(y) { }
 
@@ -85,8 +87,8 @@ template<class T>
 inline Vector<T> operator *(const Vector<T> &v1, const Vector<T> &v2) {
        return Vector<T>(v1.X() * v2.X(), v1.Y() * v2.Y());
 }
-template<class T>
-inline Vector<T> operator *(const Vector<T> &v, T s) {
+template<class T, class U>
+inline Vector<T> operator *(const Vector<T> &v, U s) {
        return Vector<T>(v.X() * s, v.Y() * s);
 }
 template<class T>
@@ -176,6 +178,16 @@ void Vector<Scalar>::Lock(const Vector<Scalar> &to) {
 }
 
 
+template<Uint8 i>
+Vector<int> ToInt(const Vector<Fixed<i> > &v) {
+       return Vector<int>(v.X().Int(), v.Y().Int());
+}
+template<Uint8 i>
+Vector<Fixed<i> > ToFixed(const Vector<int> &v) {
+       return Vector<Fixed<i> >(v.X(), v.Y());
+}
+
+
 }
 
-#endif /* GEOMETRY_VECTOR_H_ */
+#endif