Vector2: add explicit constructor for Vector3

Initialize from the first 2 elements.
This commit is contained in:
Beat Küng
2018-10-01 10:17:16 +02:00
committed by Lorenz Meier
parent 807472bfd7
commit 0d3bff5e00
2 changed files with 13 additions and 0 deletions
+8
View File
@@ -22,6 +22,7 @@ class Vector2 : public Vector<Type, 2>
public:
typedef Matrix<Type, 2, 1> Matrix21;
typedef Vector<Type, 3> Vector3;
Vector2() = default;
@@ -42,6 +43,13 @@ public:
v(1) = y;
}
explicit Vector2(const Vector3 & other)
{
Vector2 &v(*this);
v(0) = other(0);
v(1) = other(1);
}
Type cross(const Matrix21 & b) const {
const Vector2 &a(*this);
return a(0)*b(1, 0) - a(1)*b(0, 0);