So I wish to cast a 2D vector to 3D, where the last component should be either zero or left undefined.
I am currently doing this:
Eigen::Vector2d vec_2d = Eigen::Vector2d{0, 1};
Eigen::Vector3d vec_3d;
vec_3d.setZero();
for (int i = 0; i < vec_2d::SizeAtCompileTime; ++i) {
vec_3d[i] = vec_2d[i];
}
But I have a strong suspicion this is not optimal at all.
So for a 2D vector (0,1), the expected result would be a 3D vector (0,1,X), where X=0 or whatever, just as long as it is 3D.