diff --git a/matrix/Vector.hpp b/matrix/Vector.hpp index e5bdd43dc5..64a9fe54db 100644 --- a/matrix/Vector.hpp +++ b/matrix/Vector.hpp @@ -40,6 +40,15 @@ public: { } + template + Vector(const Slice& slice_in) + { + Vector &self(*this); + for (size_t i = 0; i + Vector2(const Slice& slice_in) : Vector(slice_in) + { + } + explicit Vector2(const Vector3 & other) { Vector2 &v(*this); diff --git a/matrix/Vector3.hpp b/matrix/Vector3.hpp index 70d503aafd..5f463b61cb 100644 --- a/matrix/Vector3.hpp +++ b/matrix/Vector3.hpp @@ -56,6 +56,11 @@ public: { } + template + Vector3(const Slice& slice_in) : Vector(slice_in) + { + } + Vector3 cross(const Matrix31 & b) const { const Vector3 &a(*this); return {a(1)*b(2,0) - a(2)*b(1,0), -a(0)*b(2,0) + a(2)*b(0,0), a(0)*b(1,0) - a(1)*b(0,0)}; diff --git a/test/slice.cpp b/test/slice.cpp index 7e4667b56a..a8db0acd47 100644 --- a/test/slice.cpp +++ b/test/slice.cpp @@ -153,6 +153,12 @@ int main() Vector2f v8 = N.slice<3,2>(0,1).diag(); Vector2f v8_check = {2, 6}; TEST(isEqual(v8,v8_check)); + Vector2f v9(N.slice<1,2>(1,1)); + Vector2f v9_check = {5, 6}; + TEST(isEqual(v9,v9_check)); + Vector3f v10(N.slice<1,3>(1,0)); + Vector3f v10_check = {4, 5, 6}; + TEST(isEqual(v10,v10_check)); // Different assignment operators SquareMatrix3f O(data);