summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/math.hpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/math.hpp b/src/math.hpp
index 2957d00..13eb36a 100644
--- a/src/math.hpp
+++ b/src/math.hpp
@@ -122,6 +122,24 @@ public:
return v;
}
+ friend vec_t<T, N> operator^(const vec_t<T, N> &a, const vec_t<T, N> &b)
+ {
+ vec_t<T, N> r;
+
+ for (size_t i = 0; i < N; i++)
+ r[i] = a[i] * b[i];
+
+ return r;
+ }
+
+ friend vec_t<T, N> &operator^=(vec_t<T, N> &v, const vec_t<T, N> &b)
+ {
+ for (size_t i = 0; i < N; i++)
+ v[i] *= b[i];
+
+ return v;
+ }
+
friend T operator*(const vec_t<T, N> &a, const vec_t<T, N> &b)
{
T r = (T)0;
@@ -209,6 +227,11 @@ public:
return atan2(v[1], v[0]);
}
+ vec_t<T, N> norm(void)
+ {
+ return *this / len();
+ }
+
// Compatibility with SFML
template <typename U>