summaryrefslogtreecommitdiffstats
path: root/vector
diff options
context:
space:
mode:
Diffstat (limited to 'vector')
-rw-r--r--vector/vector.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/vector/vector.cpp b/vector/vector.cpp
index d5f0c36..8057cdd 100644
--- a/vector/vector.cpp
+++ b/vector/vector.cpp
@@ -1,10 +1,11 @@
#include <iostream>
-#include <iterator>
#include <cassert>
+#include <cmath>
+
#include <array>
-#include <initializer_list>
#include <algorithm>
+#include <initializer_list>
template<typename T, std::size_t d>
@@ -146,11 +147,16 @@ public:
template<std::size_t n>
vec2(const basic_vec<T, n>& other) : basic_vec<T, 2>(other) {}
- T angle();
+ T polar();
static vec3<T> cross(const vec2<T>& rhs, const vec2<T>& lhs);
};
template<typename T>
+T vec2<T>::polar() {
+ return std::atan2(this->at(0), this->at(1));
+}
+
+template<typename T>
vec3<T> vec2<T>::cross(const vec2<T>& rhs, const vec2<T>& lhs) {
return vec3<T>::cross(vec3<T>(rhs), vec3<T>(lhs));
}