Construct Vector from Slice<1,M> alias row()

This commit is contained in:
kamilritz
2020-08-06 16:15:05 +02:00
committed by Julian Kent
parent a126be0882
commit 6ed5dbc2db
4 changed files with 25 additions and 0 deletions
+9
View File
@@ -40,6 +40,15 @@ public:
{
}
template<size_t P, size_t Q, size_t DUMMY = 1>
Vector(const Slice<Type, 1, M, P, Q>& slice_in)
{
Vector &self(*this);
for (size_t i = 0; i<M; i++) {
self(i) = slice_in(0, i);
}
}
inline const Type &operator()(size_t i) const
{
assert(i < M);
+5
View File
@@ -48,6 +48,11 @@ public:
{
}
template<size_t P, size_t Q>
Vector2(const Slice<Type, 1, 2, P, Q>& slice_in) : Vector<Type, 2>(slice_in)
{
}
explicit Vector2(const Vector3 & other)
{
Vector2 &v(*this);
+5
View File
@@ -56,6 +56,11 @@ public:
{
}
template<size_t P, size_t Q>
Vector3(const Slice<Type, 1, 3, P, Q>& slice_in) : Vector<Type, 3>(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)};