summaryrefslogtreecommitdiffstats
path: root/vector/vector.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vector/vector.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/vector/vector.cpp b/vector/vector.cpp
index f422db2..0322ee2 100644
--- a/vector/vector.cpp
+++ b/vector/vector.cpp
@@ -36,7 +36,7 @@ basic_vec<T, d>::basic_vec(const basic_vec<T, n>& other) {
static_assert(d >= n);
this->fill(static_cast<T>(0));
for (std::size_t i = 0; i < n; i++) {
- this[i] = other[i];
+ this->at(i) = other.at(i);
}
}
@@ -103,12 +103,19 @@ template<typename T, std::size_t d>
class vec: public basic_vec<T, d> {
public:
vec(std::initializer_list<T> l) : basic_vec<T, d>(l) {}
+
+ template<std::size_t n>
+ vec(const basic_vec<T, n>& other) : basic_vec<T, d>(other) {}
};
template<typename T>
class vec3 : public basic_vec<T, 3> {
public:
vec3(std::initializer_list<T> l) : basic_vec<T, 3>(l) {}
+
+ template<std::size_t n>
+ vec3(const basic_vec<T, n>& other) : basic_vec<T, 3>(other) {}
+
static vec3<T> cross(const vec3<T>& rhs, const vec3<T>& lhs);
};
@@ -125,6 +132,10 @@ template<typename T>
class vec2: public basic_vec<T, 2> {
public:
vec2(std::initializer_list<T> l) : basic_vec<T, 2>(l) {}
+
+ template<std::size_t n>
+ vec2(const basic_vec<T, n>& other) : basic_vec<T, 2>(other) {}
+
T angle();
static vec3<T> cross(const vec2<T>& rhs, const vec2<T>& lhs);
};